@f1api/sdk
Version:
An SDK for accessing the https://f1api.dev API.
1,004 lines (992 loc) • 30.9 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
Circuits: () => Circuits,
Drivers: () => Drivers,
F1Api: () => F1Api,
Races: () => Races,
Results: () => Results,
Seasons: () => Seasons,
Standings: () => Standings,
Teams: () => Teams
});
module.exports = __toCommonJS(index_exports);
// src/base.ts
var import_isomorphic_unfetch = __toESM(require("isomorphic-unfetch"));
var Base = class {
constructor() {
this.baseUrl = "https://f1api.dev/api";
}
async request(endpoint, options) {
const url = `${this.baseUrl}${endpoint}`;
const headers = {
"Content-Type": "application/json"
};
const config = __spreadProps(__spreadValues({}, options), {
headers
});
try {
const response = await (0, import_isomorphic_unfetch.default)(url, config);
if (response.ok) {
return response.json();
}
throw new Error(response.statusText);
} catch (error) {
console.log(error);
throw new Error(error);
}
}
};
// src/utils.ts
function applyMixins(derivedCtor, baseCtors) {
baseCtors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
const descriptor = Object.getOwnPropertyDescriptor(
baseCtor.prototype,
name
);
if (descriptor) {
Object.defineProperty(derivedCtor.prototype, name, descriptor);
}
});
});
}
function buildQueryParams(limit, offset) {
const params = {};
if (limit !== void 0) params.limit = String(limit);
if (offset !== void 0) params.offset = String(offset);
const queryString = new URLSearchParams(params).toString();
return queryString;
}
// src/circuits/circuits.ts
var resourceName = "circuits";
var Circuits = class extends Base {
/**
* getCircuits - Returns the list of the f1 circuits.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<CircuitsApiResponse>} Object array with the circuits and his info.
*
* @example
* ```ts
* const circuits = await getCircuits({ limit: 1, offset: 0 });
* ```
*/
getCircuits({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${resourceName}?${queryString}`;
return this.request(url);
}
/**
* getCircuit - Returns the specific circuit based on his id.
*
* @param {number} [id] - Circuit id, ej: spa
* @returns {Promise<CircuitApiResponse>} Object with the circuit and his info.
*
* @example
* ```ts
* const circuit = await getCircuit({ id: "spa" });
* ```
*/
getCircuit({ id }) {
const url = `/${resourceName}/${id}`;
return this.request(url);
}
/**
* getCircuitsByYear - Returns the list of the f1 circuits of a specific year.
*
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<CircuitsApiResponse>} Object array with the circuits and his info.
*
* @example
* ```ts
* const circuits = await getCircuitsByYear({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getCircuitsByYear({
year,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${resourceName}?${queryString}`;
return this.request(url);
}
};
// src/drivers/drivers.ts
var resourceName2 = "drivers";
var Drivers = class extends Base {
/**
* getDrivers - Returns all the f1 drivers in the database.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriversApiResponse>} Object array with the drivers and his info.
*
* @example
* ```ts
* const drivers = await getDrivers({ limit: 1, offset: 0 });
* ```
*/
getDrivers({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${resourceName2}?${queryString}`;
return this.request(url);
}
/**
* getDriversByYear - Returns all the f1 drivers of a specific year.
*
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriversApiResponse>} Object array with the drivers and his info.
*
* @example
* ```ts
* const drivers = await getDriversByYear({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getDriversByYear({
year,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${resourceName2}?${queryString}`;
return this.request(url);
}
/**
* getDriver - Returns a specific f1 driver based on his id.
*
* @param {string} [id] - Driver id, ej: alonso.
* @returns {Promise<DriverApiResponse>} Object with the driver and his info.
*
* @example
* ```ts
* const driver = await getDriver({ id: "alonso" });
* ```
*/
getDriver({ id }) {
const url = `/${resourceName2}/${id}`;
return this.request(url);
}
/**
* getCurrentDrivers - Returns all the f1 drivers of the current year.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriversApiResponse>} Object array with the drivers and his info.
*
* @example
* ```ts
* const drivers = await getCurrentDrivers({ limit: 1, offset: 0 });
* ```
*/
getCurrentDrivers({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/${resourceName2}?${queryString}`;
return this.request(url);
}
/**
* getDrivers - Returns a specific f1 driver of the current year based on his id, with his results.
*
* @param {string} [id] - Driver id, ej: alonso.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriversApiResponse>} Object array with the driver and his results info.
*
* @example
* ```ts
* const drivers = await getCurrentDriver({ id: "alonso", limit: 1, offset: 0 });
* ```
*/
getCurrentDriver({
id,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/${resourceName2}/${id}?${queryString}`;
return this.request(url);
}
/**
* getDrivers - Returns a specific f1 driver of the specific year based on his id, with his results.
*
* @param {string} [id] - Driver id, ej: alonso.
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriversApiResponse>} Object array with the driver and his results info.
*
* @example
* ```ts
* const drivers = await getDriverByYear({ id: "alonso", year: 2023, limit: 1, offset: 0 });
* ```
*/
getDriverByYear({
year,
id,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${resourceName2}/${id}?${queryString}`;
return this.request(url);
}
};
// src/races/races.ts
var Races = class extends Base {
/**
* getRacesByYear - returns all the races of a specific year.
*
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<RacesApiResponse>} Object array with the races and his info.
*
* @example
* ```ts
* const races = await getRacesByYear({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getRacesByYear({
year,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}?${queryString}`;
return this.request(url);
}
/**
* getCurrentRaces - returns all the races of the current year.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<RacesApiResponse>} Object array with the races and his info.
*
* @example
* ```ts
* const races = await getCurrentRaces({ limit: 1, offset: 0 });
* ```
*/
getCurrentRaces({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current?${queryString}`;
return this.request(url);
}
/**
* getRaceInfo - returns details of a specific race based on the year and the round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @returns {Promise<RaceApiResponse>} Object with the race info.
*
* @example
* ```ts
* const race = await getRaceInfo({ year: 2023, round: 1 });
* ```
*/
getRaceInfo({
year,
round
}) {
const url = `/${year}/${round}`;
return this.request(url);
}
/**
* getLastRace - returns info of the last race (completed) of the current year.
*
* @returns {Promise<RaceApiResponse>} Object array with the races and his info.
*
* @example
* ```ts
* const race = await getLastRace();
* ```
*/
getLastRace() {
const url = `/current/last`;
return this.request(url);
}
/**
* getNextRace - returns info of the next race of the calendar of the current year.
*
* @returns {Promise<RaceApiResponse>} Object array with the races and his info.
*
* @example
* ```ts
* const race = await getNextRace();
* ```
*/
getNextRace() {
const url = `/current/next`;
return this.request(url);
}
};
// src/results/results.ts
var Results = class extends Base {
/**
* getFp1Results - Returns fp1 results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp1ResultsApiResponse>} Object array with the fp1 results of the race.
*
* @example
* ```ts
* const results = await getFp1Results({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getFp1Results({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/fp1?${queryString}`;
return this.request(url);
}
/**
* getLastFp1Results - Returns fp1 results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp1ResultsApiResponse>} Object array with the fp1 results of the race.
*
* @example
* ```ts
* const results = await getLastFp1Results({ limit: 1, offset: 0 });
* ```
*/
getLastFp1Results({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/fp1?${queryString}`;
return this.request(url);
}
/**
* getFp2Results - Returns fp2 results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp2ResultsApiResponse>} Object array with the fp2 results of the race.
*
* @example
* ```ts
* const results = await getFp2Results({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getFp2Results({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/fp2?${queryString}`;
return this.request(url);
}
/**
* getLastFp2Results - Returns fp2 results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp2ResultsApiResponse>} Object array with the fp2 results of the race.
*
* @example
* ```ts
* const results = await getLastFp2Results({ limit: 1, offset: 0 });
* ```
*/
getLastFp2Results({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/fp2?${queryString}`;
return this.request(url);
}
/**
* getFp3Results - Returns fp3 results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp3ResultsApiResponse>} Object array with the fp3 results of the race.
*
* @example
* ```ts
* const results = await getFp3Results({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getFp3Results({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/fp3?${queryString}`;
return this.request(url);
}
/**
* getLastFp3Results - Returns fp3 results of a the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<Fp3ResultsApiResponse>} Object array with the fp3 results of the race.
*
* @example
* ```ts
* const results = await getLastFp3Results({ limit: 1, offset: 0 });
* ```
*/
getLastFp3Results({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/fp3?${queryString}`;
return this.request(url);
}
/**
* getQualyResults - Returns qualy results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<QualyResultsApiResponse>} Object array with the qualy results of the race.
*
* @example
* ```ts
* const results = await getQualyResults({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getQualyResults({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/qualy?${queryString}`;
return this.request(url);
}
/**
* getLastQualyResults - Returns qualy results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<QualyResultsApiResponse>} Object array with the qualy results of the race.
*
* @example
* ```ts
* const results = await getLastQualyResults({ limit: 1, offset: 0 });
* ```
*/
getLastQualyResults({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/qualy?${queryString}`;
return this.request(url);
}
/**
* getRaceResults - Returns race results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<RaceResultsApiResponse>} Object array with the race results of the race.
*
* @example
* ```ts
* const results = await getRaceResults({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getRaceResults({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/race?${queryString}`;
return this.request(url);
}
/**
* getLastRaceResults - Returns race results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<RaceResultsApiResponse>} Object array with the race results of the race.
*
* @example
* ```ts
* const results = await getLastRaceResults({ limit: 1, offset: 0 });
* ```
*/
getLastRaceResults({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/race?${queryString}`;
return this.request(url);
}
/**
* getSprintRaceResults - Returns sprint results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<SprintRaceResultsApiResponse>} Object array with the sprint race results of the race.
*
* @example
* ```ts
* const results = await getSprintRaceResults({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getSprintRaceResults({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/sprint/race?${queryString}`;
return this.request(url);
}
/**
* getLastSprintRaceResults - Returns sprint results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<SprintRaceResultsApiResponse>} Object array with the sprint race results of the race.
*
* @example
* ```ts
* const results = await getLastSprintRaceResults({ limit: 1, offset: 0 });
* ```
*/
getLastSprintRaceResults({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/sprint/race?${queryString}`;
return this.request(url);
}
/**
* getSprintQualyResults - Returns sprint qualy results of a race, based on the year and round.
*
* @param {number} [year] - Year of the season.
* @param {number} [round] - Round of the race.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<SprintQualyResultsApiResponse>} Object array with the sprint qualy results of the race.
*
* @example
* ```ts
* const results = await getSprintQualyResults({ year: 2023, round: 1, limit: 1, offset: 0 });
* ```
*/
getSprintQualyResults({
year,
round,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${round}/sprint/qualy?${queryString}`;
return this.request(url);
}
/**
* getLastSprintQualyResults - Returns sprint qualy results of the last race, of the current season.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<SprintQualyResultsApiResponse>} Object array with the sprint qualy results of the race.
*
* @example
* ```ts
* const results = await getLastSprintQualyResults({ limit: 1, offset: 0 });
* ```
*/
getLastSprintQualyResults({
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/last/sprint/qualy?${queryString}`;
return this.request(url);
}
};
// src/seasons/seasons.ts
var resourceName3 = "seasons";
var Seasons = class extends Base {
/**
* getSeasons - Returns the list of the f1 seasons.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<SeasonsApiResponse>} Object array with the seasons and his info.
*
* @example
* ```ts
* const seasons = await getSeasons({ limit: 1, offset: 0 });
* ```
*/
getSeasons({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${resourceName3}?${queryString}`;
return this.request(url);
}
};
// src/standings/standings.ts
var driverStandings = "drivers-championship";
var constructorStandings = "constructors-championship";
var Standings = class extends Base {
/**
* getDriverStandings - Returns the driver standings of a specific year.
*
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<DriverStandingsApiResponse>} Object array with the driver standings with the info of the driver and his team.
*
* @example
* ```ts
* const standings = await getDriverStandings({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getDriverStandings({
year,
limit,
offset
}) {
const queryParams = buildQueryParams(limit, offset);
const url = `/${year}/${driverStandings}?${queryParams}`;
return this.request(url);
}
/**
* getCurrentDriverStandings - Returns the driver standings of the current year.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamWithDriversApiResponse>} Object array with the driver standings with the info of the driver and his team.
*
* @example
* ```ts
* const standings = await getCurrentDriverStandings({ limit: 1, offset: 0 });
* ```
*/
getCurrentDriverStandings({
limit,
offset
} = {}) {
const queryParams = buildQueryParams(limit, offset);
const url = `/current/${driverStandings}?${queryParams}`;
return this.request(url);
}
/**
* getConstructorStandings - Returns the team standings of the specific year.
*
* @param {number} [year] - Year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<ConstructorStandingsApiResponse>} Object array with the team standings with the info of the team.
*
* @example
* ```ts
* const standings = await getConstructorStandings({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getConstructorStandings({
year,
limit,
offset
}) {
const queryParams = buildQueryParams(limit, offset);
const url = `/${year}/${constructorStandings}?${queryParams}`;
return this.request(url);
}
/**
* getCurrentConstructorStandings - Returns the team standings of the current year.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<ConstructorStandingsApiResponse>} Object array with the team standings with the info of the team.
*
* @example
* ```ts
* const standings = await getCurrentConstructorStandings({ limit: 1, offset: 0 });
* ```
*/
getCurrentConstructorStandings({
limit,
offset
} = {}) {
const queryParams = buildQueryParams(limit, offset);
const url = `/current/${constructorStandings}?${queryParams}`;
return this.request(url);
}
};
// src/teams/teams.ts
var resourceName4 = "teams";
var Teams = class extends Base {
/**
* getTeams - Returns all the f1 teams inside the database.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamsApiResponse>} Object array with the teams.
*
* @example
* ```ts
* const teams = await getTeams({ limit: 1, offset: 0 });
* ```
*/
getTeams({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${resourceName4}?${queryString}`;
return this.request(url);
}
/**
* getTeam - Returns a f1 team based on his id.
*
* @param {string} [id] - The id of the team.
* @returns {Promise<TeamApiResponse>} Team object.
*
* @example
* ```ts
* const team = await getTeam({ id: "ferrari"});
* ```
*/
getTeam({ id }) {
const url = `/${resourceName4}/${id}`;
return this.request(url);
}
/**
* getTeamsByYear - Returns all the f1 teams of a specific year.
*
* @param {number} year - The year of the season.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamsApiResponse>} Object array with the teams.
*
* @example
* ```ts
* const teams = await getTeamsByYear({ year: 2023, limit: 1, offset: 0 });
* ```
*/
getTeamsByYear({
year,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${resourceName4}?${queryString}`;
return this.request(url);
}
/**
* getCurrentTeams - Returns all the f1 teams of the current year.
*
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamsApiResponse>} Object array with the teams.
*
* @example
* ```ts
* const teams = await getCurrentTeams({ limit: 1, offset: 0 });
* ```
*/
getCurrentTeams({
limit,
offset
} = {}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/${resourceName4}?${queryString}`;
return this.request(url);
}
/**
* getTeamByYear - Returns a f1 team of a specific year based on his id.
*
* @param {number} [year] - Maximum number of results to return.
* @param {string} [id] - Team id ej: ferrari.
* @returns {Promise<TeamApiResponse>} Team object.
*
* @example
* ```ts
* const team = await getTeamByYear({ year: 2023, id: "ferrari"});
* ```
*/
getTeamByYear({
year,
id
}) {
const url = `/${year}/${resourceName4}/${id}`;
return this.request(url);
}
/**
* getCurrentTeam - Returns a f1 team of the current year based on his id.
*
* @param {string} [id] - Team id ej: ferrari.
* @returns {Promise<TeamApiResponse>} Team object.
*
* @example
* ```ts
* const team = await getCurrentTeam({ id: "ferrari"});
* ```
*/
getCurrentTeam({ id }) {
const url = `/current/${resourceName4}/${id}`;
return this.request(url);
}
/**
* getTeamByYear - Returns a f1 team with his drivers info of a specific year based on his id.
*
* @param {number} [year] - Maximum number of results to return.
* @param {string} [id] - Team id ej: ferrari.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamWithDriversApiResponse>} Object array with the teams.
*
* @example
* ```ts
* const teams = await getTeamByYearWithDrivers({ year: 2023, id: "ferrari", limit: 1, offset: 0 });
* ```
*/
getTeamByYearWithDrivers({
year,
id,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/${year}/${resourceName4}/${id}/drivers?${queryString}`;
return this.request(url);
}
/**
* getCurrentTeamWithDrivers - Returns a team with his drivers based on the current year and the team id.
*
* @param {string} [id] - Team id ej: ferrari.
* @param {number} [limit] - Maximum number of results to return.
* @param {number} [offset] - Number of results to skip.
* @returns {Promise<TeamWithDriversApiResponse>} Object array with the teams.
*
* @example
* ```ts
* const teams = await getCurrentTeamWithDrivers({ id: "ferrari", limit: 1, offset: 0 });
* ```
*/
getCurrentTeamWithDrivers({
id,
limit,
offset
}) {
const queryString = buildQueryParams(limit, offset);
const url = `/current/${resourceName4}/${id}/drivers?${queryString}`;
return this.request(url);
}
};
// src/index.ts
var F1Api = class extends Base {
};
applyMixins(F1Api, [
Seasons,
Circuits,
Standings,
Drivers,
Teams,
Races,
Results
]);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Circuits,
Drivers,
F1Api,
Races,
Results,
Seasons,
Standings,
Teams
});