.NET library which provides a simple interface for the official Fantasy Premier League API (https://fantasy.premierleague.com).
PM> Install-Package FplClient
All clients need to be provided with a HttpClient
upon construction, e.g, new HttpClient()
You can access team data for a given gameweek by using the FplEntryClient
.
var client = new FplEntryClient(new HttpClient());
var team = await client.GetTeam(teamId: 12345, gameweek: 1);
This will return the FplEventEntry data.
The team id can be found the url of any gameweek points page: https://fantasy.premierleague.com/a/team/_**12345**_/event/1
You can access team histories (chips used, gameweek ranks, season ranks, etc) by using the FplEntryHistoryClient
.
var client = new FplEntryHistoryClient(new HttpClient());
var team = await client.GetTeam(teamId: 12345);
This will return the FplEntryHistory data.
You can access league data by using the FplLeagueClient
.
Different data formats are returned depending on whether the league types is Classic or Head to Head.
The league id can be found the url of the league page: https://fantasy.premierleague.com/a/leagues/standings/_**313**_/classic
var client = new FplLeagueClient(new HttpClient());
// First page
var classicLeagueData = await client.GetClassicLeague(leagueId: 313);
// Include page number for subsequent pages
var classicLeagueData = await client.GetClassicLeague(leagueId: 313, page: 2);
This will return the FplClassicLeague data.
var client = new FplLeagueClient(new HttpClient());
// First page
var h2hData = await client.GetHeadToHeadLeague(leagueId: 12345);
This will return the FplHeadToHeadLeague data.
You can access player data by using the FplLeagueClient
.
var client = new FplPlayerClient(new HttpClient());
// First page
var players = await client.GetAllPlayers();
This will return all the FplPlayer data as an IEnumerable<FplPlayer>
.
var client = new FplPlayerClient(new HttpClient());
// First page
var playerData = await client.GetPlayer(playerId: 1);
This will return the FplPlayerSummary data.
var client = new FplFixtureClient(new HttpClient());
var fixtures = await client.GetFixtures();
This will return all the FplFixture data as an IEnumerable<FplFixture>
.
var client = new FplFixtureClient(new HttpClient());
var fixtures = await client.GetFixtures(8);
This will return all the FplFixture data as an IEnumerable<FplFixture>
for gameweek 8.
If you have any problems or suggestions please create an issue or a pull request