This package provides easy access to Fantasy Premier League (FPL) data through the FPL API. It allows you to fetch detailed player information, bootstrap data, and combine them for enriched player data, all with simple functions that return structured data.
- Fetch Bootstrap Static Data: Get general FPL data such as teams, players, and their details.
- Fetch Player Summary: Retrieve detailed information about a specific player, including their performance.
- Fetch Player's Bootstrap Data: Get player data directly from the bootstrap API endpoint.
- Combine Bootstrap & Element Data: Combine bootstrap and player summary data into a single object for easy use.
- And Many More: Check repo.
You can install the package via npm:
npm install fpl-sdk
The getBootsrapStaticData()
function fetches general static data about the players, teams, and FPL setup.
import { getBootsrapStaticData } from "fpl-sdk";
async function fetchBootstrapData() {
const data = await getBootsrapStaticData();
console.log(data);
}
fetchBootstrapData();
The getPlayerSummary(playerId: number)
function returns detailed information about a specific player, including performance statistics like total points, form, and transfers.
import { getPlayerSummary } from "fpl-sdk";
async function fetchPlayerSummary(playerId: number) {
const playerData = await getPlayerSummary(playerId);
console.log(playerData);
}
fetchPlayerSummary(12345); // Use the player ID
The getPlayerBootstrapData(playerId: number)
function fetches the player's bootstrap data from the FPL API, including their basic statistics.
import { getPlayerBootstrapData } from "fpl-sdk";
async function fetchPlayerBootstrapData(playerId: number) {
const playerData = await getPlayerBootstrapData(playerId);
console.log(playerData);
}
fetchPlayerBootstrapData(12345); // Use the player ID
The getCombinedData(playerId: number)
function combines both the bootstrap and element player data into a single object. This function is helpful if you want a comprehensive view of a player.
import { getCombinedData } from "fpl-sdk";
async function fetchCombinedPlayerData(playerId: number) {
const combinedData = await getCombinedData(playerId);
console.log(combinedData);
}
fetchCombinedPlayerData(12345); // Use the player ID
The getAllFixtures
function returns all fixtures of the season Gameweek 1 - 38.
import { getAllFixtures } from "fpl-sdk";
async function fetchAllFixtures() {
const seasonFixtures = await getAllFixtures();
console.log(seasonFixtures);
}
fetchAllFixtures();
The getGameWeekFixtures(gwNumber: number)
function returns all fixtures of the season. Takes gameweek/event number(1-38).
import { getGameWeekFixtures } from "fpl-sdk";
async function fetchGameWeekFixtures() {
const gwFixtures = await getGameWeekFixtures(1);
console.log(gwFixtures);
}
fetchGameWeekFixtures();
The getUpcomingGameweekNumber
function returns the gameweek number of the next live gameweek.
import { getUpcomingGameweekNumber } from "fpl-sdk";
async function fetchUpcomingGameWeekNumber() {
const gw = await getUpcomingGameweekNumber();
console.log(gw);
}
fetchUpcomingGameWeekNumber();
The getAllUpcomingFixtures
function returns all upcoming season fixtures sorted by kick-off time.
import { getUpcomingGameweekNumber } from "fpl-sdk";
async function fetchAllUpcomingSeasonFixtures() {
const upcomingFixtures = await getAllUpcomingFixtures();
console.log(upcomingFixtures);
}
fetchAllUpcomingSeasonFixtures();
More coming soon
This package uses TypeScript and provides the following types for the FPL data:
- Bootstrap: Contains all the general FPL setup data (teams, players, etc.).
- PlayerSummary: Contains detailed player performance data.
- Element: The basic data for each player.
- Player: A combined type that includes both bootstrap and element data for a player.
- Fixture: Basic type for a fixture
This package is licensed under the MIT License.