MarkdownCopies this page as Markdown, ready to paste into an AI assistant.
Sports API
3 Sports 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
- POSTSports Game Score
/v1/run/sports.gameOne game by id: teams, start time, status, score, period scores and live clock. Ids come from sports.games or odds.events.1 creditper call - POSTSports Leagues
/v1/run/sports.leaguesThe leagues the sports scores and odds APIs accept: NFL, NBA, MLB, NHL, college football and basketball, and the top soccer leagues, with sport, country and home time zone.1 creditper call - POSTSports Scores and Schedules
/v1/run/sports.gamesGames for a league on a date or short date range: teams, start time, status (scheduled, live, final, postponed), score, period scores and live clock.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, sports.game:
curl -sS -X POST "https://api.primaryapi.com/v1/run/sports.game" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id":"WyJvIiw3NzM0MCwiYnVuZGVzbGlnYSJd","clock":false}'const res = await fetch('https://api.primaryapi.com/v1/run/sports.game', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: 'WyJvIiw3NzM0MCwiYnVuZGVzbGlnYSJd',
clock: false,
}),
});
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/sports.game",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"id": "WyJvIiw3NzM0MCwiYnVuZGVzbGlnYSJd",
"clock": False,
},
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.