fpl-graphql
A GraphQL wrapper for the Fantasy Premier League API, using node and graphql-yoga. Demo
Important notice
As of September 2020, fpl-graphql needs update to reflect possible changes in the premier league API. Contributions are welcome. Right now I am a little busy so it would take some time for fpl-graphql to work again. Starting from 20/21 season, request-promise is used. (axios, fetch and other alternatives did not seem to work, which is very odd.)
FPL Rest API endpoints
- https://fantasy.premierleague.com/api/bootstrap-static/ : events (gameweeks), teams, players, game settings, phases, and elements (players)
- https://fantasy.premierleague.com/api/fixtures/ : fixtures
- https://fantasy.premierleague.com/api/element-summary/{player_id}/ : stats of a given player.
- https://fantasy.premierleague.com/api/event/{event_id}/live/ : live stats, by player, for a given gameweek, and how much points he scored in fantasy.
- https://fantasy.premierleague.com/api/entry/{entry_id}/history/ : data for a given entry (a fantasy team) for the past gameweeks of the season, plus past seasons.
- https://fantasy.premierleague.com/api/entry/{entry_id}/event/{event_id}/picks/ : data of picks of a given fpl team for a given entry (gameweek)
Usage
- Download or clone this repository
git clone https://github.com/lastmaj/fpl-graphql.git
- Move to the project directory and install dependencies
cd fpl-graphql
npm install
- Start the server
npm start
The server will run at http://localhost:4000 with a graphql playground (browse docs and schema to know more about queries)
Example
Aguero's live stats for the 4the gameweek. You didn't captain him did you ?
Feel free to fork 🍴
If it helps you build something awesome, let me know. Contributions are happily welcome.