@apicity/thesportsdb
v0.6.2
Published
TheSportsDB V1 and V2 sports data API provider.
Maintainers
Readme
@apicity/thesportsdb
TheSportsDB V1 and V2 sports data API provider.
Runtime dependencies:
zod@^4.4.3— request schemas attached to endpoint methods as.schema; response schemas exported
Installation
npm install @apicity/thesportsdb
# or
pnpm add @apicity/thesportsdbQuick Start
import { createTheSportsDB } from "@apicity/thesportsdb";
const thesportsdb = createTheSportsDB({ apiKey: process.env.THESPORTSDB_API_KEY });V2 Authentication
V1 calls default to TheSportsDB's free 123 key in the URL path when
apiKey is omitted. V2 is premium-only and sends the same apiKey in
the X-API-KEY header; V2 methods throw locally if no key is configured.
const thesportsdb = createTheSportsDB({
apiKey: process.env.THESPORTSDB_API_KEY!,
});
const teams = await thesportsdb.v2.search.team({
teamName: "Manchester United",
});For V1 premium calls, the same apiKey option is encoded into the
path segment instead of a header:
const premiumV1 = createTheSportsDB({
apiKey: process.env.THESPORTSDB_API_KEY!,
});
const broadcasts = await premiumV1.v1.eventstv({
channel: "Peacock_Premium",
});Operational Notes
All implemented TheSportsDB endpoints are read-only GET calls. The
provider does not expose mutating endpoints.
The implemented API surface has no pagination parameters. Upstream
responses use endpoint-specific wrapper arrays and documented result
limits; empty and no-result wrappers remain representable as null or
empty arrays.
Non-2xx responses throw TheSportsDBError with status and parsed
body where possible. Rate-limit responses keep their upstream 429
status and body. V2 methods throw a local 401 before fetch when no
apiKey is configured for X-API-KEY authentication.
Search Examples
TheSportsDB V1 uses the free 123 key by default. Pass apiKey only
when you have a premium key.
import { createTheSportsDB } from "@apicity/thesportsdb";
const thesportsdb = createTheSportsDB();
const teams = await thesportsdb.v1.searchTeams({
team: "Arsenal",
});
const events = await thesportsdb.v1.searchEvents({
event: "Arsenal_vs_Chelsea",
season: "2016-2017",
date: "2015-04-26",
});
const filename = await thesportsdb.v1.searchFilename({
filename: "English_Premier_League_2015-04-26_Arsenal_vs_Chelsea",
});
const players = await thesportsdb.v1.searchPlayers({
player: "Danny Welbeck",
});
const venues = await thesportsdb.v1.searchVenues({
venue: "Wembley",
});No-result V1 searches preserve TheSportsDB's nullable wrapper arrays,
such as { teams: null } or { player: null }.
Player Lookup Examples
Player lookup, honours, former-team, milestone, contract, result, and statistics routes use TheSportsDB's numeric player id.
import { createTheSportsDB } from "@apicity/thesportsdb";
const thesportsdb = createTheSportsDB({
apiKey: process.env.THESPORTSDB_API_KEY,
});
const player = await thesportsdb.v1.lookupplayer({ idPlayer: 34145937 });
const honours = await thesportsdb.v1.lookuphonours({ idPlayer: 34147178 });
const stats = await thesportsdb.v1.lookupplayerstats({ idPlayer: 34146304 });No-result responses preserve TheSportsDB's wrapper key with a null
value, for example { players: null }.
V1 uses an API key in the URL path. The provider defaults to the public
free key 123; pass apiKey to use your own key.
V2 uses the same apiKey option as an X-API-KEY header and is
available under thesportsdb.v2.
const league = await thesportsdb.v1.lookup.league({ idLeague: 4328 });
const table = await thesportsdb.v1.lookup.table({
idLeague: 4328,
season: "2020-2021",
});
const team = await thesportsdb.v1.lookup.team({ idTeam: 133604 });
const nextLeagueEvents = await thesportsdb.v2.schedule.next.league({
idLeague: 4328,
});
const liveSoccer = await thesportsdb.v2.livescore.bySport({
sport: "soccer",
});V2 is premium-only and sends the same apiKey as an X-API-KEY
header. V2 lookup method names mirror the path segments:
const player = await thesportsdb.v2.lookup.player({ idPlayer: 34172575 });
const lineup = await thesportsdb.v2.lookup.eventLineup({
idEvent: 1937584,
});
const highlights = await thesportsdb.v2.lookup.eventHighlights({
idEvent: 2044892,
});API Reference
84 endpoints across 40 groups. Each method mirrors an upstream URL path.
all
GET https://www.thesportsdb.com/api/v2/json/all/countries
const res = await thesportsdb.v2.all.countries({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/all/leagues
const res = await thesportsdb.v2.all.leagues({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/all/sports
const res = await thesportsdb.v2.all.sports({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
allCountries
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_countries.php
const res = await thesportsdb.v1.allCountries({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
allLeagues
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_leagues.php
const res = await thesportsdb.v1.allLeagues({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
allSports
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_sports.php
const res = await thesportsdb.v1.allSports({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventResults
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventresults.php{query}
const res = await thesportsdb.v1.eventResults({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventsday
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsday.php{query}
const res = await thesportsdb.v1.eventsday({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventshighlights
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventshighlights.php{query}
const res = await thesportsdb.v1.eventshighlights({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventslast
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventslast.php{query}
const res = await thesportsdb.v1.eventslast({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventsnext
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsnext.php{query}
const res = await thesportsdb.v1.eventsnext({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventsnextleague
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsnextleague.php{query}
const res = await thesportsdb.v1.eventsnextleague({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventspastleague
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventspastleague.php{query}
const res = await thesportsdb.v1.eventspastleague({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventsseason
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsseason.php{query}
const res = await thesportsdb.v1.eventsseason({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
eventstv
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventstv.php{query}
const res = await thesportsdb.v1.eventstv({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
filter
GET https://www.thesportsdb.com/api/v2/json/filter/tv/channel/{channel}
const res = await thesportsdb.v2.filter.tv.channel({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/filter/tv/channelid/{idChannel}
const res = await thesportsdb.v2.filter.tv.channelid({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/filter/tv/country/{country}
const res = await thesportsdb.v2.filter.tv.country({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/filter/tv/day/{date}
const res = await thesportsdb.v2.filter.tv.day({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/filter/tv/sport/{sport}
const res = await thesportsdb.v2.filter.tv.sport({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
list
GET https://www.thesportsdb.com/api/v2/json/list/players/{idTeam}
const res = await thesportsdb.v2.list.players({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/list/seasonposters/{idLeague}
const res = await thesportsdb.v2.list.seasonposters({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/list/seasons/{idLeague}
const res = await thesportsdb.v2.list.seasons({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/list/teams/{idLeague}
const res = await thesportsdb.v2.list.teams({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
livescore
GET https://www.thesportsdb.com/api/v2/json/livescore/all
const res = await thesportsdb.v2.livescore.all({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/livescore/{leagueId}
const res = await thesportsdb.v2.livescore.byLeague({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/livescore/{sport}
const res = await thesportsdb.v2.livescore.bySport({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookup
GET https://www.thesportsdb.com/api/v2/json/lookup/event/{idEvent}
const res = await thesportsdb.v2.lookup.event({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_highlights/{idEvent}
const res = await thesportsdb.v2.lookup.eventHighlights({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_lineup/{idEvent}
const res = await thesportsdb.v2.lookup.eventLineup({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_results/{idEvent}
const res = await thesportsdb.v2.lookup.eventResults({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_stats/{idEvent}
const res = await thesportsdb.v2.lookup.eventStats({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_timeline/{idEvent}
const res = await thesportsdb.v2.lookup.eventTimeline({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/event_tv/{idEvent}
const res = await thesportsdb.v2.lookup.eventTv({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/league/{idLeague}
const res = await thesportsdb.v2.lookup.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player/{idPlayer}
const res = await thesportsdb.v2.lookup.player({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_contracts/{idPlayer}
const res = await thesportsdb.v2.lookup.playerContracts({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_honours/{idPlayer}
const res = await thesportsdb.v2.lookup.playerHonours({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_milestones/{idPlayer}
const res = await thesportsdb.v2.lookup.playerMilestones({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_results/{idPlayer}
const res = await thesportsdb.v2.lookup.playerResults({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_stats/{idPlayer}
const res = await thesportsdb.v2.lookup.playerStats({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/player_teams/{idPlayer}
const res = await thesportsdb.v2.lookup.playerTeams({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/team/{idTeam}
const res = await thesportsdb.v2.lookup.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/team_equipment/{idTeam}
const res = await thesportsdb.v2.lookup.teamEquipment({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/lookup/venue/{idVenue}
const res = await thesportsdb.v2.lookup.venue({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupequipment.php{query}
const res = await thesportsdb.v1.lookup.equipment({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupleague.php{query}
const res = await thesportsdb.v1.lookup.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptable.php{query}
const res = await thesportsdb.v1.lookup.table({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupteam.php{query}
const res = await thesportsdb.v1.lookup.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupvenue.php{query}
const res = await thesportsdb.v1.lookup.venue({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupAllPlayers
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookup_all_players.php{query}
const res = await thesportsdb.v1.lookupAllPlayers({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupcontracts
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupcontracts.php?id={idPlayer}
const res = await thesportsdb.v1.lookupcontracts({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupEvent
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupevent.php{query}
const res = await thesportsdb.v1.lookupEvent({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupEventStats
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupeventstats.php{query}
const res = await thesportsdb.v1.lookupEventStats({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupformerteams
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupformerteams.php?id={idPlayer}
const res = await thesportsdb.v1.lookupformerteams({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookuphonours
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuphonours.php?id={idPlayer}
const res = await thesportsdb.v1.lookuphonours({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupLineup
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuplineup.php{query}
const res = await thesportsdb.v1.lookupLineup({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupmilestones
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupmilestones.php?id={idPlayer}
const res = await thesportsdb.v1.lookupmilestones({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupplayer
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupplayer.php?id={idPlayer}
const res = await thesportsdb.v1.lookupplayer({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupplayerstats
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupplayerstats.php?id={idPlayer}
const res = await thesportsdb.v1.lookupplayerstats({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupTimeline
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptimeline.php{query}
const res = await thesportsdb.v1.lookupTimeline({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
lookupTv
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptv.php{query}
const res = await thesportsdb.v1.lookupTv({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
playerresults
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/playerresults.php?id={idPlayer}
const res = await thesportsdb.v1.playerresults({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
schedule
GET https://www.thesportsdb.com/api/v2/json/schedule/full/team/{idTeam}
const res = await thesportsdb.v2.schedule.full.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/league/{idLeague}/{season}
const res = await thesportsdb.v2.schedule.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/next/league/{idLeague}
const res = await thesportsdb.v2.schedule.next.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/next/team/{idTeam}
const res = await thesportsdb.v2.schedule.next.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/next/venue/{idVenue}
const res = await thesportsdb.v2.schedule.next.venue({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/previous/league/{idLeague}
const res = await thesportsdb.v2.schedule.previous.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/previous/team/{idTeam}
const res = await thesportsdb.v2.schedule.previous.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/schedule/previous/venue/{idVenue}
const res = await thesportsdb.v2.schedule.previous.venue({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
search
GET https://www.thesportsdb.com/api/v2/json/search/event/{eventName}
const res = await thesportsdb.v2.search.event({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/search/league/{leagueName}
const res = await thesportsdb.v2.search.league({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/search/player/{playerName}
const res = await thesportsdb.v2.search.player({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/search/team/{teamName}
const res = await thesportsdb.v2.search.team({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
GET https://www.thesportsdb.com/api/v2/json/search/venue/{venueName}
const res = await thesportsdb.v2.search.venue({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchAllLeagues
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_leagues.php{query}
const res = await thesportsdb.v1.searchAllLeagues({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchAllSeasons
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_seasons.php{query}
const res = await thesportsdb.v1.searchAllSeasons({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchAllTeams
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_teams.php{query}
const res = await thesportsdb.v1.searchAllTeams({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchEvents
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchevents.php{query}
const res = await thesportsdb.v1.searchEvents({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchFilename
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchfilename.php{query}
const res = await thesportsdb.v1.searchFilename({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchPlayers
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchplayers.php{query}
const res = await thesportsdb.v1.searchPlayers({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchTeams
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchteams.php{query}
const res = await thesportsdb.v1.searchTeams({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
searchVenues
GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchvenues.php{query}
const res = await thesportsdb.v1.searchVenues({ /* ... */ });Source: packages/provider/thesportsdb/src/thesportsdb.ts
Part of the apicity monorepo.
License
MIT — see LICENSE.
