MarkdownCopies this page as Markdown, ready to paste into an AI assistant.
Lottery API
3 Lottery endpoints behind one key, priced in credits per call and routed to the cheapest healthy source.
On this page
Knowledge & Data · 3 endpoints · from 1 credit per call
Endpoints
- POSTLottery Games
/v1/run/lottery.gamesThe lottery games with results available: Powerball, Mega Millions and New York draw games, with their ball names, draw times and history start.1 creditper call - POSTLottery Number Checker
/v1/run/lottery.checkCompare your numbers with a Powerball, Mega Millions or New York lottery draw: which numbers matched, whether the special ball matched, and the match pattern.1 creditper call - POSTLottery Results
/v1/run/lottery.resultsWinning numbers for Powerball, Mega Millions and New York lottery games: the latest draw or any past draw by date or date range, newest first.1 creditper call
Calling them
Every endpoint on this page is one POST to https://api.primaryapi.com/v1/run/{sku} with your API key and a JSON body. Responses share one envelope, so code written for one endpoint handles the others. For example, lottery.games:
curl -sS -X POST "https://api.primaryapi.com/v1/run/lottery.games" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'const res = await fetch('https://api.primaryapi.com/v1/run/lottery.games', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/lottery.games",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"])New to PrimaryAPI? Start with the Quickstart, then read Making requests.