@apicity/thesportsdb 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1512 -0
- package/dist/src/example.d.ts +8 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +121 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/thesportsdb.d.ts +3 -0
- package/dist/src/thesportsdb.d.ts.map +1 -0
- package/dist/src/thesportsdb.js +815 -0
- package/dist/src/thesportsdb.js.map +1 -0
- package/dist/src/types.d.ts +1333 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +11 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/zod.d.ts +477 -0
- package/dist/src/zod.d.ts.map +1 -0
- package/dist/src/zod.js +551 -0
- package/dist/src/zod.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import { attachExamples } from "./example.js";
|
|
2
|
+
import { TheSportsDBError } from "./types.js";
|
|
3
|
+
import { TheSportsDBEquipmentLookupRequestSchema, TheSportsDBEventLookupRequestSchema, TheSportsDBEventsDayRequestSchema, TheSportsDBEventsHighlightsRequestSchema, TheSportsDBEventsSeasonRequestSchema, TheSportsDBEventsTVRequestSchema, TheSportsDBFilterTvChannelIdRequestSchema, TheSportsDBFilterTvChannelRequestSchema, TheSportsDBFilterTvCountryRequestSchema, TheSportsDBFilterTvDayRequestSchema, TheSportsDBFilterTvSportRequestSchema, TheSportsDBLeagueEventsRequestSchema, TheSportsDBLeagueIdRequestSchema, TheSportsDBLeagueLookupRequestSchema, TheSportsDBLeagueScheduleRequestSchema, TheSportsDBLeagueSeasonScheduleRequestSchema, TheSportsDBLiveScoreLeagueRequestSchema, TheSportsDBLiveScoreSportRequestSchema, TheSportsDBLookupAllPlayersRequestSchema, TheSportsDBPlayerIdRequestSchema, TheSportsDBSearchAllLeaguesRequestSchema, TheSportsDBSearchAllSeasonsRequestSchema, TheSportsDBSearchAllTeamsRequestSchema, TheSportsDBSearchEventRequestSchema, TheSportsDBSearchEventsRequestSchema, TheSportsDBSearchFilenameRequestSchema, TheSportsDBSearchLeagueRequestSchema, TheSportsDBSearchPlayerRequestSchema, TheSportsDBSearchPlayersRequestSchema, TheSportsDBSearchTeamRequestSchema, TheSportsDBSearchTeamsRequestSchema, TheSportsDBSearchVenueRequestSchema, TheSportsDBSearchVenuesRequestSchema, TheSportsDBTableLookupRequestSchema, TheSportsDBTeamEventsRequestSchema, TheSportsDBTeamIdRequestSchema, TheSportsDBTeamLookupRequestSchema, TheSportsDBTeamScheduleRequestSchema, TheSportsDBV2EventLookupRequestSchema, TheSportsDBV2LeagueLookupRequestSchema, TheSportsDBV2PlayerLookupRequestSchema, TheSportsDBV2TeamLookupRequestSchema, TheSportsDBV2VenueLookupRequestSchema, TheSportsDBVenueLookupRequestSchema, TheSportsDBVenueScheduleRequestSchema, } from "./zod.js";
|
|
4
|
+
export function createTheSportsDB(opts) {
|
|
5
|
+
const v1BaseURL = (opts?.baseURL ?? "https://www.thesportsdb.com/api/v1/json").replace(/\/+$/, "");
|
|
6
|
+
const v2BaseURL = (opts?.v2BaseURL ?? "https://www.thesportsdb.com/api/v2/json").replace(/\/+$/, "");
|
|
7
|
+
const apiKey = encodeURIComponent(opts?.apiKey ?? "123");
|
|
8
|
+
const v2ApiKey = opts?.apiKey;
|
|
9
|
+
const doFetch = opts?.fetch ?? fetch;
|
|
10
|
+
const timeout = opts?.timeout ?? 30000;
|
|
11
|
+
function attachAbortHandler(signal, controller) {
|
|
12
|
+
if (signal.aborted) {
|
|
13
|
+
controller.abort();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
signal.addEventListener("abort", () => controller.abort(), { once: true });
|
|
17
|
+
}
|
|
18
|
+
function formatErrorMessage(status, body) {
|
|
19
|
+
if (typeof body === "object" && body !== null) {
|
|
20
|
+
const b = body;
|
|
21
|
+
if (typeof b.error === "string") {
|
|
22
|
+
return `TheSportsDB API error ${status}: ${b.error}`;
|
|
23
|
+
}
|
|
24
|
+
if (b.error?.message) {
|
|
25
|
+
return `TheSportsDB API error ${status}: ${b.error.message}`;
|
|
26
|
+
}
|
|
27
|
+
if (b.message) {
|
|
28
|
+
return `TheSportsDB API error ${status}: ${b.message}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (typeof body === "string" && body.length > 0) {
|
|
32
|
+
return `TheSportsDB API error ${status}: ${body}`;
|
|
33
|
+
}
|
|
34
|
+
return `TheSportsDB API error: ${status}`;
|
|
35
|
+
}
|
|
36
|
+
function createLocalError(status, message) {
|
|
37
|
+
return new TheSportsDBError(formatErrorMessage(status, { error: message }), status, { error: message });
|
|
38
|
+
}
|
|
39
|
+
function requireV2ApiKey() {
|
|
40
|
+
if (!v2ApiKey || v2ApiKey.trim().length === 0) {
|
|
41
|
+
throw createLocalError(401, "TheSportsDB V2 requires apiKey for X-API-KEY authentication");
|
|
42
|
+
}
|
|
43
|
+
return v2ApiKey;
|
|
44
|
+
}
|
|
45
|
+
async function parseResponseBody(res) {
|
|
46
|
+
const text = await res.text();
|
|
47
|
+
if (!text) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(text);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function makeJsonRequest(method, requestBaseURL, path, signal, headers) {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
60
|
+
if (signal) {
|
|
61
|
+
attachAbortHandler(signal, controller);
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const init = {
|
|
65
|
+
method,
|
|
66
|
+
signal: controller.signal,
|
|
67
|
+
};
|
|
68
|
+
if (headers) {
|
|
69
|
+
init.headers = headers;
|
|
70
|
+
}
|
|
71
|
+
const res = await doFetch(`${requestBaseURL}${path}`, init);
|
|
72
|
+
clearTimeout(timeoutId);
|
|
73
|
+
const resBody = await parseResponseBody(res);
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
throw new TheSportsDBError(formatErrorMessage(res.status, resBody), res.status, resBody);
|
|
76
|
+
}
|
|
77
|
+
return resBody;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
clearTimeout(timeoutId);
|
|
81
|
+
if (error instanceof TheSportsDBError)
|
|
82
|
+
throw error;
|
|
83
|
+
throw new TheSportsDBError(`TheSportsDB request failed: ${error}`, 500);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function makeV1Request(method, path, requestBaseURL, signal) {
|
|
87
|
+
return makeJsonRequest(method, requestBaseURL, path, signal);
|
|
88
|
+
}
|
|
89
|
+
async function makeV2Request(method, path, requestBaseURL, signal) {
|
|
90
|
+
return makeJsonRequest(method, requestBaseURL, path, signal, {
|
|
91
|
+
"X-API-KEY": requireV2ApiKey(),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function buildPath(...segments) {
|
|
95
|
+
return `/${segments.map((s) => encodeURIComponent(String(s))).join("/")}`;
|
|
96
|
+
}
|
|
97
|
+
function buildQuery(params) {
|
|
98
|
+
const qs = new URLSearchParams();
|
|
99
|
+
for (const [key, value] of Object.entries(params)) {
|
|
100
|
+
if (value !== undefined && value !== null) {
|
|
101
|
+
qs.append(key, String(value));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const query = qs.toString();
|
|
105
|
+
return query ? `?${query}` : "";
|
|
106
|
+
}
|
|
107
|
+
function eventIdQuery(req) {
|
|
108
|
+
return buildQuery({ id: req.idEvent });
|
|
109
|
+
}
|
|
110
|
+
function flagQueryValue(value) {
|
|
111
|
+
if (value === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
if (typeof value === "boolean") {
|
|
115
|
+
return value ? 1 : 0;
|
|
116
|
+
}
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
// sig-ok: V1 PHP script names exposed as catalog methods.
|
|
120
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_sports.php
|
|
121
|
+
// Docs: https://thedatadb.readme.io/reference/getallsports
|
|
122
|
+
const allSports = Object.assign(async (signal) => {
|
|
123
|
+
return makeV1Request("GET", `/${apiKey}/all_sports.php`, v1BaseURL, signal);
|
|
124
|
+
}, { schema: undefined });
|
|
125
|
+
// sig-ok: V1 PHP script names exposed as catalog methods.
|
|
126
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_countries.php
|
|
127
|
+
// Docs: https://thedatadb.readme.io/reference/getallcountries
|
|
128
|
+
const allCountries = Object.assign(async (signal) => {
|
|
129
|
+
return makeV1Request("GET", `/${apiKey}/all_countries.php`, v1BaseURL, signal);
|
|
130
|
+
}, { schema: undefined });
|
|
131
|
+
// sig-ok: V1 PHP script names exposed as catalog methods.
|
|
132
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/all_leagues.php
|
|
133
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-list
|
|
134
|
+
const allLeagues = Object.assign(async (signal) => {
|
|
135
|
+
return makeV1Request("GET", `/${apiKey}/all_leagues.php`, v1BaseURL, signal);
|
|
136
|
+
}, { schema: undefined });
|
|
137
|
+
// sig-ok: semantic V1 lookup namespace over TheSportsDB PHP script names.
|
|
138
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupleague.php{query}
|
|
139
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
140
|
+
const league = Object.assign(async (req, signal) => {
|
|
141
|
+
const query = buildQuery({ id: req.idLeague });
|
|
142
|
+
return makeV1Request("GET", `/${apiKey}/lookupleague.php${query}`, v1BaseURL, signal);
|
|
143
|
+
}, { schema: TheSportsDBLeagueLookupRequestSchema });
|
|
144
|
+
// sig-ok: semantic V1 lookup namespace over TheSportsDB PHP script names.
|
|
145
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptable.php{query}
|
|
146
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
147
|
+
const table = Object.assign(async (req, signal) => {
|
|
148
|
+
const query = buildQuery({
|
|
149
|
+
l: req.idLeague,
|
|
150
|
+
s: req.season,
|
|
151
|
+
});
|
|
152
|
+
return makeV1Request("GET", `/${apiKey}/lookuptable.php${query}`, v1BaseURL, signal);
|
|
153
|
+
}, { schema: TheSportsDBTableLookupRequestSchema });
|
|
154
|
+
// sig-ok: semantic V1 lookup namespace over TheSportsDB PHP script names.
|
|
155
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupteam.php{query}
|
|
156
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
157
|
+
const team = Object.assign(async (req, signal) => {
|
|
158
|
+
const query = buildQuery({ id: req.idTeam });
|
|
159
|
+
return makeV1Request("GET", `/${apiKey}/lookupteam.php${query}`, v1BaseURL, signal);
|
|
160
|
+
}, { schema: TheSportsDBTeamLookupRequestSchema });
|
|
161
|
+
// sig-ok: semantic V1 lookup namespace over TheSportsDB PHP script names.
|
|
162
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupequipment.php{query}
|
|
163
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
164
|
+
const equipment = Object.assign(async (req, signal) => {
|
|
165
|
+
const query = buildQuery({ id: req.idTeam });
|
|
166
|
+
return makeV1Request("GET", `/${apiKey}/lookupequipment.php${query}`, v1BaseURL, signal);
|
|
167
|
+
}, { schema: TheSportsDBEquipmentLookupRequestSchema });
|
|
168
|
+
// sig-ok: semantic V1 lookup namespace over TheSportsDB PHP script names.
|
|
169
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupvenue.php{query}
|
|
170
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
171
|
+
const venue = Object.assign(async (req, signal) => {
|
|
172
|
+
const query = buildQuery({ id: req.idVenue });
|
|
173
|
+
return makeV1Request("GET", `/${apiKey}/lookupvenue.php${query}`, v1BaseURL, signal);
|
|
174
|
+
}, { schema: TheSportsDBVenueLookupRequestSchema });
|
|
175
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/league/{idLeague}
|
|
176
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
177
|
+
const v2League = Object.assign(async (req, signal) => {
|
|
178
|
+
return makeV2Request("GET", buildPath("lookup", "league", req.idLeague), v2BaseURL, signal);
|
|
179
|
+
}, { schema: TheSportsDBV2LeagueLookupRequestSchema });
|
|
180
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/team/{idTeam}
|
|
181
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
182
|
+
const v2Team = Object.assign(async (req, signal) => {
|
|
183
|
+
return makeV2Request("GET", buildPath("lookup", "team", req.idTeam), v2BaseURL, signal);
|
|
184
|
+
}, { schema: TheSportsDBV2TeamLookupRequestSchema });
|
|
185
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/team_equipment/{idTeam}
|
|
186
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
187
|
+
const v2TeamEquipment = Object.assign(async (req, signal) => {
|
|
188
|
+
return makeV2Request("GET", buildPath("lookup", "team_equipment", req.idTeam), v2BaseURL, signal);
|
|
189
|
+
}, { schema: TheSportsDBV2TeamLookupRequestSchema });
|
|
190
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player/{idPlayer}
|
|
191
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
192
|
+
const v2Player = Object.assign(async (req, signal) => {
|
|
193
|
+
return makeV2Request("GET", buildPath("lookup", "player", req.idPlayer), v2BaseURL, signal);
|
|
194
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
195
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_contracts/{idPlayer}
|
|
196
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
197
|
+
const v2PlayerContracts = Object.assign(async (req, signal) => {
|
|
198
|
+
return makeV2Request("GET", buildPath("lookup", "player_contracts", req.idPlayer), v2BaseURL, signal);
|
|
199
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
200
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_results/{idPlayer}
|
|
201
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
202
|
+
const v2PlayerResults = Object.assign(async (req, signal) => {
|
|
203
|
+
return makeV2Request("GET", buildPath("lookup", "player_results", req.idPlayer), v2BaseURL, signal);
|
|
204
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
205
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_honours/{idPlayer}
|
|
206
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
207
|
+
const v2PlayerHonours = Object.assign(async (req, signal) => {
|
|
208
|
+
return makeV2Request("GET", buildPath("lookup", "player_honours", req.idPlayer), v2BaseURL, signal);
|
|
209
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
210
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_milestones/{idPlayer}
|
|
211
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
212
|
+
const v2PlayerMilestones = Object.assign(async (req, signal) => {
|
|
213
|
+
return makeV2Request("GET", buildPath("lookup", "player_milestones", req.idPlayer), v2BaseURL, signal);
|
|
214
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
215
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_teams/{idPlayer}
|
|
216
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
217
|
+
const v2PlayerTeams = Object.assign(async (req, signal) => {
|
|
218
|
+
return makeV2Request("GET", buildPath("lookup", "player_teams", req.idPlayer), v2BaseURL, signal);
|
|
219
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
220
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/player_stats/{idPlayer}
|
|
221
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
222
|
+
const v2PlayerStats = Object.assign(async (req, signal) => {
|
|
223
|
+
return makeV2Request("GET", buildPath("lookup", "player_stats", req.idPlayer), v2BaseURL, signal);
|
|
224
|
+
}, { schema: TheSportsDBV2PlayerLookupRequestSchema });
|
|
225
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event/{idEvent}
|
|
226
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
227
|
+
const v2Event = Object.assign(async (req, signal) => {
|
|
228
|
+
return makeV2Request("GET", buildPath("lookup", "event", req.idEvent), v2BaseURL, signal);
|
|
229
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
230
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_lineup/{idEvent}
|
|
231
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
232
|
+
const v2EventLineup = Object.assign(async (req, signal) => {
|
|
233
|
+
return makeV2Request("GET", buildPath("lookup", "event_lineup", req.idEvent), v2BaseURL, signal);
|
|
234
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
235
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_results/{idEvent}
|
|
236
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
237
|
+
const v2EventResults = Object.assign(async (req, signal) => {
|
|
238
|
+
return makeV2Request("GET", buildPath("lookup", "event_results", req.idEvent), v2BaseURL, signal);
|
|
239
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
240
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_stats/{idEvent}
|
|
241
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
242
|
+
const v2EventStats = Object.assign(async (req, signal) => {
|
|
243
|
+
return makeV2Request("GET", buildPath("lookup", "event_stats", req.idEvent), v2BaseURL, signal);
|
|
244
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
245
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_timeline/{idEvent}
|
|
246
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
247
|
+
const v2EventTimeline = Object.assign(async (req, signal) => {
|
|
248
|
+
return makeV2Request("GET", buildPath("lookup", "event_timeline", req.idEvent), v2BaseURL, signal);
|
|
249
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
250
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_tv/{idEvent}
|
|
251
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
252
|
+
const v2EventTv = Object.assign(async (req, signal) => {
|
|
253
|
+
return makeV2Request("GET", buildPath("lookup", "event_tv", req.idEvent), v2BaseURL, signal);
|
|
254
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
255
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/event_highlights/{idEvent}
|
|
256
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
257
|
+
const v2EventHighlights = Object.assign(async (req, signal) => {
|
|
258
|
+
return makeV2Request("GET", buildPath("lookup", "event_highlights", req.idEvent), v2BaseURL, signal);
|
|
259
|
+
}, { schema: TheSportsDBV2EventLookupRequestSchema });
|
|
260
|
+
// GET https://www.thesportsdb.com/api/v2/json/lookup/venue/{idVenue}
|
|
261
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-lookup
|
|
262
|
+
const v2Venue = Object.assign(async (req, signal) => {
|
|
263
|
+
return makeV2Request("GET", buildPath("lookup", "venue", req.idVenue), v2BaseURL, signal);
|
|
264
|
+
}, { schema: TheSportsDBV2VenueLookupRequestSchema });
|
|
265
|
+
const lookup = {
|
|
266
|
+
league,
|
|
267
|
+
table,
|
|
268
|
+
team,
|
|
269
|
+
equipment,
|
|
270
|
+
venue,
|
|
271
|
+
};
|
|
272
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
273
|
+
// GET https://www.thesportsdb.com/api/v2/json/search/league/{leagueName}
|
|
274
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-search
|
|
275
|
+
const searchLeague = Object.assign(async (req, signal) => {
|
|
276
|
+
return makeV2Request("GET", buildPath("search", "league", req.leagueName), v2BaseURL, signal);
|
|
277
|
+
}, { schema: TheSportsDBSearchLeagueRequestSchema });
|
|
278
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
279
|
+
// GET https://www.thesportsdb.com/api/v2/json/search/team/{teamName}
|
|
280
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-search
|
|
281
|
+
const searchTeam = Object.assign(async (req, signal) => {
|
|
282
|
+
return makeV2Request("GET", buildPath("search", "team", req.teamName), v2BaseURL, signal);
|
|
283
|
+
}, { schema: TheSportsDBSearchTeamRequestSchema });
|
|
284
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
285
|
+
// GET https://www.thesportsdb.com/api/v2/json/search/player/{playerName}
|
|
286
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-search
|
|
287
|
+
const searchPlayer = Object.assign(async (req, signal) => {
|
|
288
|
+
return makeV2Request("GET", buildPath("search", "player", req.playerName), v2BaseURL, signal);
|
|
289
|
+
}, { schema: TheSportsDBSearchPlayerRequestSchema });
|
|
290
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
291
|
+
// GET https://www.thesportsdb.com/api/v2/json/search/event/{eventName}
|
|
292
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-search
|
|
293
|
+
const searchEvent = Object.assign(async (req, signal) => {
|
|
294
|
+
return makeV2Request("GET", buildPath("search", "event", req.eventName), v2BaseURL, signal);
|
|
295
|
+
}, { schema: TheSportsDBSearchEventRequestSchema });
|
|
296
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
297
|
+
// GET https://www.thesportsdb.com/api/v2/json/search/venue/{venueName}
|
|
298
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-search
|
|
299
|
+
const searchVenue = Object.assign(async (req, signal) => {
|
|
300
|
+
return makeV2Request("GET", buildPath("search", "venue", req.venueName), v2BaseURL, signal);
|
|
301
|
+
}, { schema: TheSportsDBSearchVenueRequestSchema });
|
|
302
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
303
|
+
// GET https://www.thesportsdb.com/api/v2/json/all/countries
|
|
304
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-all
|
|
305
|
+
const v2AllCountries = Object.assign(async (signal) => {
|
|
306
|
+
return makeV2Request("GET", buildPath("all", "countries"), v2BaseURL, signal);
|
|
307
|
+
}, { schema: undefined });
|
|
308
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
309
|
+
// GET https://www.thesportsdb.com/api/v2/json/all/sports
|
|
310
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-all
|
|
311
|
+
const v2AllSports = Object.assign(async (signal) => {
|
|
312
|
+
return makeV2Request("GET", buildPath("all", "sports"), v2BaseURL, signal);
|
|
313
|
+
}, { schema: undefined });
|
|
314
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
315
|
+
// GET https://www.thesportsdb.com/api/v2/json/all/leagues
|
|
316
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-all
|
|
317
|
+
const v2AllLeagues = Object.assign(async (signal) => {
|
|
318
|
+
return makeV2Request("GET", buildPath("all", "leagues"), v2BaseURL, signal);
|
|
319
|
+
}, { schema: undefined });
|
|
320
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
321
|
+
// GET https://www.thesportsdb.com/api/v2/json/list/teams/{idLeague}
|
|
322
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-list
|
|
323
|
+
const listTeams = Object.assign(async (req, signal) => {
|
|
324
|
+
return makeV2Request("GET", buildPath("list", "teams", req.idLeague), v2BaseURL, signal);
|
|
325
|
+
}, { schema: TheSportsDBLeagueIdRequestSchema });
|
|
326
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
327
|
+
// GET https://www.thesportsdb.com/api/v2/json/list/seasons/{idLeague}
|
|
328
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-list
|
|
329
|
+
const listSeasons = Object.assign(async (req, signal) => {
|
|
330
|
+
return makeV2Request("GET", buildPath("list", "seasons", req.idLeague), v2BaseURL, signal);
|
|
331
|
+
}, { schema: TheSportsDBLeagueIdRequestSchema });
|
|
332
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
333
|
+
// GET https://www.thesportsdb.com/api/v2/json/list/seasonposters/{idLeague}
|
|
334
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-list
|
|
335
|
+
const listSeasonposters = Object.assign(async (req, signal) => {
|
|
336
|
+
return makeV2Request("GET", buildPath("list", "seasonposters", req.idLeague), v2BaseURL, signal);
|
|
337
|
+
}, { schema: TheSportsDBLeagueIdRequestSchema });
|
|
338
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
339
|
+
// GET https://www.thesportsdb.com/api/v2/json/list/players/{idTeam}
|
|
340
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-list
|
|
341
|
+
const listPlayers = Object.assign(async (req, signal) => {
|
|
342
|
+
return makeV2Request("GET", buildPath("list", "players", req.idTeam), v2BaseURL, signal);
|
|
343
|
+
}, { schema: TheSportsDBTeamIdRequestSchema });
|
|
344
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
345
|
+
// GET https://www.thesportsdb.com/api/v2/json/filter/tv/day/{date}
|
|
346
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-filter
|
|
347
|
+
const filterTvDay = Object.assign(async (req, signal) => {
|
|
348
|
+
return makeV2Request("GET", buildPath("filter", "tv", "day", req.date), v2BaseURL, signal);
|
|
349
|
+
}, { schema: TheSportsDBFilterTvDayRequestSchema });
|
|
350
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
351
|
+
// GET https://www.thesportsdb.com/api/v2/json/filter/tv/country/{country}
|
|
352
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-filter
|
|
353
|
+
const filterTvCountry = Object.assign(async (req, signal) => {
|
|
354
|
+
return makeV2Request("GET", buildPath("filter", "tv", "country", req.country), v2BaseURL, signal);
|
|
355
|
+
}, { schema: TheSportsDBFilterTvCountryRequestSchema });
|
|
356
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
357
|
+
// GET https://www.thesportsdb.com/api/v2/json/filter/tv/sport/{sport}
|
|
358
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-filter
|
|
359
|
+
const filterTvSport = Object.assign(async (req, signal) => {
|
|
360
|
+
return makeV2Request("GET", buildPath("filter", "tv", "sport", req.sport), v2BaseURL, signal);
|
|
361
|
+
}, { schema: TheSportsDBFilterTvSportRequestSchema });
|
|
362
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
363
|
+
// GET https://www.thesportsdb.com/api/v2/json/filter/tv/channel/{channel}
|
|
364
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-filter
|
|
365
|
+
const filterTvChannel = Object.assign(async (req, signal) => {
|
|
366
|
+
return makeV2Request("GET", buildPath("filter", "tv", "channel", req.channel), v2BaseURL, signal);
|
|
367
|
+
}, { schema: TheSportsDBFilterTvChannelRequestSchema });
|
|
368
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
369
|
+
// GET https://www.thesportsdb.com/api/v2/json/filter/tv/channelid/{idChannel}
|
|
370
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-filter
|
|
371
|
+
const filterTvChannelid = Object.assign(async (req, signal) => {
|
|
372
|
+
return makeV2Request("GET", buildPath("filter", "tv", "channelid", req.idChannel), v2BaseURL, signal);
|
|
373
|
+
}, { schema: TheSportsDBFilterTvChannelIdRequestSchema });
|
|
374
|
+
// sig-ok: V1 PHP script names exposed as list methods.
|
|
375
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_leagues.php{query}
|
|
376
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-list
|
|
377
|
+
const searchAllLeagues = Object.assign(async (req, signal) => {
|
|
378
|
+
const query = buildQuery({
|
|
379
|
+
c: req.country,
|
|
380
|
+
s: req.sport,
|
|
381
|
+
});
|
|
382
|
+
return makeV1Request("GET", `/${apiKey}/search_all_leagues.php${query}`, v1BaseURL, signal);
|
|
383
|
+
}, { schema: TheSportsDBSearchAllLeaguesRequestSchema });
|
|
384
|
+
// sig-ok: V1 PHP script names exposed as list methods.
|
|
385
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_seasons.php{query}
|
|
386
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-list
|
|
387
|
+
const searchAllSeasons = Object.assign(async (req, signal) => {
|
|
388
|
+
const query = buildQuery({
|
|
389
|
+
id: req.idLeague,
|
|
390
|
+
poster: flagQueryValue(req.poster),
|
|
391
|
+
badge: flagQueryValue(req.badge),
|
|
392
|
+
description: flagQueryValue(req.description),
|
|
393
|
+
});
|
|
394
|
+
return makeV1Request("GET", `/${apiKey}/search_all_seasons.php${query}`, v1BaseURL, signal);
|
|
395
|
+
}, { schema: TheSportsDBSearchAllSeasonsRequestSchema });
|
|
396
|
+
// sig-ok: V1 PHP script names exposed as list methods.
|
|
397
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/search_all_teams.php{query}
|
|
398
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-list
|
|
399
|
+
const searchAllTeams = Object.assign(async (req, signal) => {
|
|
400
|
+
const query = buildQuery({
|
|
401
|
+
l: req.league,
|
|
402
|
+
s: req.sport,
|
|
403
|
+
c: req.country,
|
|
404
|
+
});
|
|
405
|
+
return makeV1Request("GET", `/${apiKey}/search_all_teams.php${query}`, v1BaseURL, signal);
|
|
406
|
+
}, { schema: TheSportsDBSearchAllTeamsRequestSchema });
|
|
407
|
+
// sig-ok: V1 PHP script names exposed as list methods.
|
|
408
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookup_all_players.php{query}
|
|
409
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-list
|
|
410
|
+
const lookupAllPlayers = Object.assign(async (req, signal) => {
|
|
411
|
+
const query = buildQuery({
|
|
412
|
+
id: req.idTeam,
|
|
413
|
+
});
|
|
414
|
+
return makeV1Request("GET", `/${apiKey}/lookup_all_players.php${query}`, v1BaseURL, signal);
|
|
415
|
+
}, { schema: TheSportsDBLookupAllPlayersRequestSchema });
|
|
416
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
417
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsnext.php{query}
|
|
418
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
419
|
+
const eventsnext = Object.assign(async (req, signal) => {
|
|
420
|
+
const query = buildQuery({
|
|
421
|
+
id: req.idTeam,
|
|
422
|
+
});
|
|
423
|
+
return makeV1Request("GET", `/${apiKey}/eventsnext.php${query}`, v1BaseURL, signal);
|
|
424
|
+
}, { schema: TheSportsDBTeamEventsRequestSchema });
|
|
425
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
426
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventslast.php{query}
|
|
427
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
428
|
+
const eventslast = Object.assign(async (req, signal) => {
|
|
429
|
+
const query = buildQuery({
|
|
430
|
+
id: req.idTeam,
|
|
431
|
+
});
|
|
432
|
+
return makeV1Request("GET", `/${apiKey}/eventslast.php${query}`, v1BaseURL, signal);
|
|
433
|
+
}, { schema: TheSportsDBTeamEventsRequestSchema });
|
|
434
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
435
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsnextleague.php{query}
|
|
436
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
437
|
+
const eventsnextleague = Object.assign(async (req, signal) => {
|
|
438
|
+
const query = buildQuery({
|
|
439
|
+
id: req.idLeague,
|
|
440
|
+
});
|
|
441
|
+
return makeV1Request("GET", `/${apiKey}/eventsnextleague.php${query}`, v1BaseURL, signal);
|
|
442
|
+
}, { schema: TheSportsDBLeagueEventsRequestSchema });
|
|
443
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
444
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventspastleague.php{query}
|
|
445
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
446
|
+
const eventspastleague = Object.assign(async (req, signal) => {
|
|
447
|
+
const query = buildQuery({
|
|
448
|
+
id: req.idLeague,
|
|
449
|
+
});
|
|
450
|
+
return makeV1Request("GET", `/${apiKey}/eventspastleague.php${query}`, v1BaseURL, signal);
|
|
451
|
+
}, { schema: TheSportsDBLeagueEventsRequestSchema });
|
|
452
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
453
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsday.php{query}
|
|
454
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
455
|
+
const eventsday = Object.assign(async (req, signal) => {
|
|
456
|
+
const query = buildQuery({
|
|
457
|
+
d: req.date,
|
|
458
|
+
s: req.sport,
|
|
459
|
+
l: req.league,
|
|
460
|
+
});
|
|
461
|
+
return makeV1Request("GET", `/${apiKey}/eventsday.php${query}`, v1BaseURL, signal);
|
|
462
|
+
}, { schema: TheSportsDBEventsDayRequestSchema });
|
|
463
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
464
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventsseason.php{query}
|
|
465
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
466
|
+
const eventsseason = Object.assign(async (req, signal) => {
|
|
467
|
+
const query = buildQuery({
|
|
468
|
+
id: req.idLeague,
|
|
469
|
+
s: req.season,
|
|
470
|
+
});
|
|
471
|
+
return makeV1Request("GET", `/${apiKey}/eventsseason.php${query}`, v1BaseURL, signal);
|
|
472
|
+
}, { schema: TheSportsDBEventsSeasonRequestSchema });
|
|
473
|
+
// sig-ok: V1 PHP script names exposed as schedule methods.
|
|
474
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventstv.php{query}
|
|
475
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-schedule
|
|
476
|
+
const eventstv = Object.assign(async (req, signal) => {
|
|
477
|
+
const query = buildQuery({
|
|
478
|
+
d: req.date,
|
|
479
|
+
a: req.country,
|
|
480
|
+
s: req.sport,
|
|
481
|
+
c: req.channel,
|
|
482
|
+
id: req.idChannel,
|
|
483
|
+
});
|
|
484
|
+
return makeV1Request("GET", `/${apiKey}/eventstv.php${query}`, v1BaseURL, signal);
|
|
485
|
+
}, { schema: TheSportsDBEventsTVRequestSchema });
|
|
486
|
+
// sig-ok: V1 PHP script names exposed as video methods.
|
|
487
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventshighlights.php{query}
|
|
488
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-video
|
|
489
|
+
const eventshighlights = Object.assign(async (req, signal) => {
|
|
490
|
+
const query = buildQuery({
|
|
491
|
+
d: req.date,
|
|
492
|
+
l: req.idLeague,
|
|
493
|
+
s: req.sport,
|
|
494
|
+
});
|
|
495
|
+
return makeV1Request("GET", `/${apiKey}/eventshighlights.php${query}`, v1BaseURL, signal);
|
|
496
|
+
}, { schema: TheSportsDBEventsHighlightsRequestSchema });
|
|
497
|
+
// sig-ok: V1 PHP script names exposed as search methods.
|
|
498
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchteams.php{query}
|
|
499
|
+
// Docs: https://thedatadb.readme.io/reference/getteambyname
|
|
500
|
+
const searchTeams = Object.assign(async (req, signal) => {
|
|
501
|
+
const query = buildQuery({ t: req.team });
|
|
502
|
+
return makeV1Request("GET", `/${apiKey}/searchteams.php${query}`, v1BaseURL, signal);
|
|
503
|
+
}, { schema: TheSportsDBSearchTeamsRequestSchema });
|
|
504
|
+
// sig-ok: V1 PHP script names exposed as search methods.
|
|
505
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchevents.php{query}
|
|
506
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-search
|
|
507
|
+
const searchEvents = Object.assign(async (req, signal) => {
|
|
508
|
+
const query = buildQuery({
|
|
509
|
+
e: req.event,
|
|
510
|
+
s: req.season,
|
|
511
|
+
d: req.date,
|
|
512
|
+
f: req.filename,
|
|
513
|
+
});
|
|
514
|
+
return makeV1Request("GET", `/${apiKey}/searchevents.php${query}`, v1BaseURL, signal);
|
|
515
|
+
}, { schema: TheSportsDBSearchEventsRequestSchema });
|
|
516
|
+
// sig-ok: V1 PHP script names exposed as search methods.
|
|
517
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchfilename.php{query}
|
|
518
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-search
|
|
519
|
+
const searchFilename = Object.assign(async (req, signal) => {
|
|
520
|
+
const query = buildQuery({
|
|
521
|
+
e: req.filename,
|
|
522
|
+
s: req.season,
|
|
523
|
+
});
|
|
524
|
+
return makeV1Request("GET", `/${apiKey}/searchfilename.php${query}`, v1BaseURL, signal);
|
|
525
|
+
}, { schema: TheSportsDBSearchFilenameRequestSchema });
|
|
526
|
+
// sig-ok: V1 PHP script names exposed as search methods.
|
|
527
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchplayers.php{query}
|
|
528
|
+
// Docs: https://thedatadb.readme.io/reference/getplayerbyname
|
|
529
|
+
const searchPlayers = Object.assign(async (req, signal) => {
|
|
530
|
+
const query = buildQuery({ p: req.player });
|
|
531
|
+
return makeV1Request("GET", `/${apiKey}/searchplayers.php${query}`, v1BaseURL, signal);
|
|
532
|
+
}, { schema: TheSportsDBSearchPlayersRequestSchema });
|
|
533
|
+
// sig-ok: V1 PHP script names exposed as search methods.
|
|
534
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/searchvenues.php{query}
|
|
535
|
+
// Docs: https://thedatadb.readme.io/reference/getvenuebyname
|
|
536
|
+
const searchVenues = Object.assign(async (req, signal) => {
|
|
537
|
+
const query = buildQuery({ v: req.venue });
|
|
538
|
+
return makeV1Request("GET", `/${apiKey}/searchvenues.php${query}`, v1BaseURL, signal);
|
|
539
|
+
}, { schema: TheSportsDBSearchVenuesRequestSchema });
|
|
540
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
541
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupplayer.php?id={idPlayer}
|
|
542
|
+
// Docs: https://thedatadb.readme.io/reference/getplayerbyid
|
|
543
|
+
const lookupplayer = Object.assign(async (req, signal) => {
|
|
544
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
545
|
+
return makeV1Request("GET", `/${apiKey}/lookupplayer.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
546
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
547
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
548
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuphonours.php?id={idPlayer}
|
|
549
|
+
// Docs: https://thedatadb.readme.io/reference/gethonourbyid
|
|
550
|
+
const lookuphonours = Object.assign(async (req, signal) => {
|
|
551
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
552
|
+
return makeV1Request("GET", `/${apiKey}/lookuphonours.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
553
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
554
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
555
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupformerteams.php?id={idPlayer}
|
|
556
|
+
// Docs: https://thedatadb.readme.io/reference/getformerteamsbyplayerid
|
|
557
|
+
const lookupformerteams = Object.assign(async (req, signal) => {
|
|
558
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
559
|
+
return makeV1Request("GET", `/${apiKey}/lookupformerteams.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
560
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
561
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
562
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupmilestones.php?id={idPlayer}
|
|
563
|
+
// Docs: https://thedatadb.readme.io/reference/getmilestonesbyplayerid
|
|
564
|
+
const lookupmilestones = Object.assign(async (req, signal) => {
|
|
565
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
566
|
+
return makeV1Request("GET", `/${apiKey}/lookupmilestones.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
567
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
568
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
569
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupcontracts.php?id={idPlayer}
|
|
570
|
+
// Docs: https://thedatadb.readme.io/reference/getcontractsbyplayerid
|
|
571
|
+
const lookupcontracts = Object.assign(async (req, signal) => {
|
|
572
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
573
|
+
return makeV1Request("GET", `/${apiKey}/lookupcontracts.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
574
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
575
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
576
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/playerresults.php?id={idPlayer}
|
|
577
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
578
|
+
const playerresults = Object.assign(async (req, signal) => {
|
|
579
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
580
|
+
return makeV1Request("GET", `/${apiKey}/playerresults.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
581
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
582
|
+
// sig-ok: V1 PHP script names exposed as player lookup methods.
|
|
583
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupplayerstats.php?id={idPlayer}
|
|
584
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide
|
|
585
|
+
const lookupplayerstats = Object.assign(async (req, signal) => {
|
|
586
|
+
const idPlayer = encodeURIComponent(String(req.idPlayer));
|
|
587
|
+
return makeV1Request("GET", `/${apiKey}/lookupplayerstats.php?id=${idPlayer}`, v1BaseURL, signal);
|
|
588
|
+
}, { schema: TheSportsDBPlayerIdRequestSchema });
|
|
589
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
590
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupevent.php{query}
|
|
591
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
592
|
+
const lookupEvent = Object.assign(async (req, signal) => {
|
|
593
|
+
const query = eventIdQuery(req);
|
|
594
|
+
return makeV1Request("GET", `/${apiKey}/lookupevent.php${query}`, v1BaseURL, signal);
|
|
595
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
596
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
597
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/eventresults.php{query}
|
|
598
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
599
|
+
const eventResults = Object.assign(async (req, signal) => {
|
|
600
|
+
const query = eventIdQuery(req);
|
|
601
|
+
return makeV1Request("GET", `/${apiKey}/eventresults.php${query}`, v1BaseURL, signal);
|
|
602
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
603
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
604
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuplineup.php{query}
|
|
605
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
606
|
+
const lookupLineup = Object.assign(async (req, signal) => {
|
|
607
|
+
const query = eventIdQuery(req);
|
|
608
|
+
return makeV1Request("GET", `/${apiKey}/lookuplineup.php${query}`, v1BaseURL, signal);
|
|
609
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
610
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
611
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptimeline.php{query}
|
|
612
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
613
|
+
const lookupTimeline = Object.assign(async (req, signal) => {
|
|
614
|
+
const query = eventIdQuery(req);
|
|
615
|
+
return makeV1Request("GET", `/${apiKey}/lookuptimeline.php${query}`, v1BaseURL, signal);
|
|
616
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
617
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
618
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookupeventstats.php{query}
|
|
619
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
620
|
+
const lookupEventStats = Object.assign(async (req, signal) => {
|
|
621
|
+
const query = eventIdQuery(req);
|
|
622
|
+
return makeV1Request("GET", `/${apiKey}/lookupeventstats.php${query}`, v1BaseURL, signal);
|
|
623
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
624
|
+
// sig-ok: V1 PHP script names exposed as event lookup methods.
|
|
625
|
+
// GET https://www.thesportsdb.com/api/v1/json/{apiKey}/lookuptv.php{query}
|
|
626
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v1-lookup
|
|
627
|
+
const lookupTv = Object.assign(async (req, signal) => {
|
|
628
|
+
const query = eventIdQuery(req);
|
|
629
|
+
return makeV1Request("GET", `/${apiKey}/lookuptv.php${query}`, v1BaseURL, signal);
|
|
630
|
+
}, { schema: TheSportsDBEventLookupRequestSchema });
|
|
631
|
+
const v2Lookup = {
|
|
632
|
+
league: v2League,
|
|
633
|
+
team: v2Team,
|
|
634
|
+
teamEquipment: v2TeamEquipment,
|
|
635
|
+
player: v2Player,
|
|
636
|
+
playerContracts: v2PlayerContracts,
|
|
637
|
+
playerResults: v2PlayerResults,
|
|
638
|
+
playerHonours: v2PlayerHonours,
|
|
639
|
+
playerMilestones: v2PlayerMilestones,
|
|
640
|
+
playerTeams: v2PlayerTeams,
|
|
641
|
+
playerStats: v2PlayerStats,
|
|
642
|
+
event: v2Event,
|
|
643
|
+
eventLineup: v2EventLineup,
|
|
644
|
+
eventResults: v2EventResults,
|
|
645
|
+
eventStats: v2EventStats,
|
|
646
|
+
eventTimeline: v2EventTimeline,
|
|
647
|
+
eventTv: v2EventTv,
|
|
648
|
+
eventHighlights: v2EventHighlights,
|
|
649
|
+
venue: v2Venue,
|
|
650
|
+
};
|
|
651
|
+
const v1 = {
|
|
652
|
+
allSports,
|
|
653
|
+
allCountries,
|
|
654
|
+
allLeagues,
|
|
655
|
+
lookup,
|
|
656
|
+
searchAllLeagues,
|
|
657
|
+
searchAllSeasons,
|
|
658
|
+
searchAllTeams,
|
|
659
|
+
lookupAllPlayers,
|
|
660
|
+
searchTeams,
|
|
661
|
+
searchEvents,
|
|
662
|
+
searchFilename,
|
|
663
|
+
searchPlayers,
|
|
664
|
+
searchVenues,
|
|
665
|
+
eventsnext,
|
|
666
|
+
eventslast,
|
|
667
|
+
eventsnextleague,
|
|
668
|
+
eventspastleague,
|
|
669
|
+
eventsday,
|
|
670
|
+
eventsseason,
|
|
671
|
+
eventstv,
|
|
672
|
+
eventshighlights,
|
|
673
|
+
lookupplayer,
|
|
674
|
+
lookuphonours,
|
|
675
|
+
lookupformerteams,
|
|
676
|
+
lookupmilestones,
|
|
677
|
+
lookupcontracts,
|
|
678
|
+
playerresults,
|
|
679
|
+
lookupplayerstats,
|
|
680
|
+
lookupEvent,
|
|
681
|
+
eventResults,
|
|
682
|
+
lookupLineup,
|
|
683
|
+
lookupTimeline,
|
|
684
|
+
lookupEventStats,
|
|
685
|
+
lookupTv,
|
|
686
|
+
};
|
|
687
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
688
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/next/league/{idLeague}
|
|
689
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
690
|
+
const scheduleNextLeague = Object.assign(async (req, signal) => {
|
|
691
|
+
return makeV2Request("GET", buildPath("schedule", "next", "league", req.idLeague), v2BaseURL, signal);
|
|
692
|
+
}, { schema: TheSportsDBLeagueScheduleRequestSchema });
|
|
693
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
694
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/previous/league/{idLeague}
|
|
695
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
696
|
+
const schedulePreviousLeague = Object.assign(async (req, signal) => {
|
|
697
|
+
return makeV2Request("GET", buildPath("schedule", "previous", "league", req.idLeague), v2BaseURL, signal);
|
|
698
|
+
}, { schema: TheSportsDBLeagueScheduleRequestSchema });
|
|
699
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
700
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/next/team/{idTeam}
|
|
701
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
702
|
+
const scheduleNextTeam = Object.assign(async (req, signal) => {
|
|
703
|
+
return makeV2Request("GET", buildPath("schedule", "next", "team", req.idTeam), v2BaseURL, signal);
|
|
704
|
+
}, { schema: TheSportsDBTeamScheduleRequestSchema });
|
|
705
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
706
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/previous/team/{idTeam}
|
|
707
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
708
|
+
const schedulePreviousTeam = Object.assign(async (req, signal) => {
|
|
709
|
+
return makeV2Request("GET", buildPath("schedule", "previous", "team", req.idTeam), v2BaseURL, signal);
|
|
710
|
+
}, { schema: TheSportsDBTeamScheduleRequestSchema });
|
|
711
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
712
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/next/venue/{idVenue}
|
|
713
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
714
|
+
const scheduleNextVenue = Object.assign(async (req, signal) => {
|
|
715
|
+
return makeV2Request("GET", buildPath("schedule", "next", "venue", req.idVenue), v2BaseURL, signal);
|
|
716
|
+
}, { schema: TheSportsDBVenueScheduleRequestSchema });
|
|
717
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
718
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/previous/venue/{idVenue}
|
|
719
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
720
|
+
const schedulePreviousVenue = Object.assign(async (req, signal) => {
|
|
721
|
+
return makeV2Request("GET", buildPath("schedule", "previous", "venue", req.idVenue), v2BaseURL, signal);
|
|
722
|
+
}, { schema: TheSportsDBVenueScheduleRequestSchema });
|
|
723
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
724
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/full/team/{idTeam}
|
|
725
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
726
|
+
const scheduleFullTeam = Object.assign(async (req, signal) => {
|
|
727
|
+
return makeV2Request("GET", buildPath("schedule", "full", "team", req.idTeam), v2BaseURL, signal);
|
|
728
|
+
}, { schema: TheSportsDBTeamScheduleRequestSchema });
|
|
729
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
730
|
+
// GET https://www.thesportsdb.com/api/v2/json/schedule/league/{idLeague}/{season}
|
|
731
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-schedule
|
|
732
|
+
const scheduleLeague = Object.assign(async (req, signal) => {
|
|
733
|
+
return makeV2Request("GET", buildPath("schedule", "league", req.idLeague, req.season), v2BaseURL, signal);
|
|
734
|
+
}, { schema: TheSportsDBLeagueSeasonScheduleRequestSchema });
|
|
735
|
+
// sig-ok: livescore path overload is exposed as bySport.
|
|
736
|
+
// GET https://www.thesportsdb.com/api/v2/json/livescore/{sport}
|
|
737
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-livescores
|
|
738
|
+
const livescoreBySport = Object.assign(async (req, signal) => {
|
|
739
|
+
return makeV2Request("GET", buildPath("livescore", req.sport), v2BaseURL, signal);
|
|
740
|
+
}, { schema: TheSportsDBLiveScoreSportRequestSchema });
|
|
741
|
+
// sig-ok: livescore path overload is exposed as byLeague.
|
|
742
|
+
// GET https://www.thesportsdb.com/api/v2/json/livescore/{leagueId}
|
|
743
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-livescores
|
|
744
|
+
const livescoreByLeague = Object.assign(async (req, signal) => {
|
|
745
|
+
return makeV2Request("GET", buildPath("livescore", req.leagueId), v2BaseURL, signal);
|
|
746
|
+
}, { schema: TheSportsDBLiveScoreLeagueRequestSchema });
|
|
747
|
+
// sig-ok: V2 namespace omits the fixed /api/v2/json base path.
|
|
748
|
+
// GET https://www.thesportsdb.com/api/v2/json/livescore/all
|
|
749
|
+
// Docs: https://www.thesportsdb.com/docs_api_guide#v2-livescores
|
|
750
|
+
const livescoreAll = Object.assign(async (signal) => {
|
|
751
|
+
return makeV2Request("GET", buildPath("livescore", "all"), v2BaseURL, signal);
|
|
752
|
+
}, { schema: undefined });
|
|
753
|
+
const schedule = {
|
|
754
|
+
next: {
|
|
755
|
+
league: scheduleNextLeague,
|
|
756
|
+
team: scheduleNextTeam,
|
|
757
|
+
venue: scheduleNextVenue,
|
|
758
|
+
},
|
|
759
|
+
previous: {
|
|
760
|
+
league: schedulePreviousLeague,
|
|
761
|
+
team: schedulePreviousTeam,
|
|
762
|
+
venue: schedulePreviousVenue,
|
|
763
|
+
},
|
|
764
|
+
full: {
|
|
765
|
+
team: scheduleFullTeam,
|
|
766
|
+
},
|
|
767
|
+
league: scheduleLeague,
|
|
768
|
+
};
|
|
769
|
+
const livescore = {
|
|
770
|
+
bySport: livescoreBySport,
|
|
771
|
+
byLeague: livescoreByLeague,
|
|
772
|
+
all: livescoreAll,
|
|
773
|
+
};
|
|
774
|
+
const v2 = {
|
|
775
|
+
lookup: v2Lookup,
|
|
776
|
+
schedule,
|
|
777
|
+
livescore,
|
|
778
|
+
search: {
|
|
779
|
+
league: searchLeague,
|
|
780
|
+
team: searchTeam,
|
|
781
|
+
player: searchPlayer,
|
|
782
|
+
event: searchEvent,
|
|
783
|
+
venue: searchVenue,
|
|
784
|
+
},
|
|
785
|
+
all: {
|
|
786
|
+
countries: v2AllCountries,
|
|
787
|
+
sports: v2AllSports,
|
|
788
|
+
leagues: v2AllLeagues,
|
|
789
|
+
},
|
|
790
|
+
list: {
|
|
791
|
+
teams: listTeams,
|
|
792
|
+
seasons: listSeasons,
|
|
793
|
+
seasonposters: listSeasonposters,
|
|
794
|
+
players: listPlayers,
|
|
795
|
+
},
|
|
796
|
+
filter: {
|
|
797
|
+
tv: {
|
|
798
|
+
day: filterTvDay,
|
|
799
|
+
country: filterTvCountry,
|
|
800
|
+
sport: filterTvSport,
|
|
801
|
+
channel: filterTvChannel,
|
|
802
|
+
channelid: filterTvChannelid,
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
};
|
|
806
|
+
return attachExamples({
|
|
807
|
+
v1,
|
|
808
|
+
v2,
|
|
809
|
+
get: {
|
|
810
|
+
v1,
|
|
811
|
+
v2,
|
|
812
|
+
},
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
//# sourceMappingURL=thesportsdb.js.map
|