npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fpl-api

v4.0.4

Published

A wrapper for Fantasy Premier League API

Downloads

64

Readme

FPL API

Use the public endpoints from the official api from https://fantasy.premierleague.com. Return values are typed using Typescript and kept up to date as good as possible - some variance should be expected, but it is 95% accurate. Private endpoints that require a session are not implemented yet, but hopefully they will be soon.

This can be used in the browser and with node.js.

Installation

$ npm install fpl-api

Usage

import FplApi from 'fpl-api'

You can use fpl-api in the browser by using a module bundler like webpack, rollup, etc.

Methods

fetchBootstrap

General data such as players, teams, gameweeks, etc.

import { fetchBootstrap } from 'fpl-api'

const data = await fetchBootstrap()

fetchElementSummary

Data for a player.

import { fetchElementSummary } from 'fpl-api'

const playerId = 1
const data = await fetchElementSummary(playerId)

fetchEntryEvent

Entry event data (picks, transfers, etc.).

| param | description | type | default | required | | ------- | ---------------- | ------ | ------- | -------- | | entryId | ID of an entry | number | - | true | | eventId | ID of a gameweek | number | - | true |

import { fetchEntryEvent } from 'fpl-api'

const entryId = 1
const eventId = 38
const data = await fetchEntryEvent(entryId, eventId)

fetchEventStatus

Current event status.

import { fetchEventStatus } from 'fpl-api'

const data = await fetchEventStatus()

fetchFixtures

All fixtures or fixtures in a specific gameweek.

| param | description | type | default | required | | ------- | ---------------- | ------ | --------- | -------- | | eventId | ID of a gameweek | number | undefined | false |

import { fetchFixtures } from 'fpl-api'

const data = await fetchFixtures()

fetchLive

Live data for a gameweek.

| param | description | type | default | required | | ------- | ---------------- | ------ | ------- | -------- | | eventId | ID of a gameweek | number | - | true |

import { fetchLive } from 'fpl-api'

const eventId = 33
const data = await fetchLive(eventId)

fetchEntryHistory

Entry transfers etc.

| param | description | type | default | required | | ------- | ------------------- | ------ | ------- | -------- | | entryId | ID of an entry team | number | - | true |

import { fetchEntryHistory } from 'fpl-api'

const entryId = 1
const data = await fetchEntryHistory(entryId)

fetchEntry

Get an entry.

| param | description | type | default | required | | ------- | ------------------- | ------ | ------- | -------- | | entryId | ID of an entry team | number | - | true |

import { fetchEntry } from 'fpl-api'

const entryId = 1
const data = await fetchEntry(entryId)

fetchH2HMatches

Get an entry's matches from a H2H league.

| param | description | type | default | required | | -------- | ------------------- | ------ | ------- | -------- | | leagueId | ID of a H2H league | number | - | true | | entryId | ID of an entry team | number | - | true | | page | Page number | number | 1 | true |

import { fetchH2HMatches } from 'fpl-api'

const leagueId = 1
const entryId = 1
const data = await fetchH2HMatches(leagueId, entryId)

fetchH2HLeagueStandings

Get H2H league standings page.

| param | description | type | default | required | | ---------------------- | --------------------------- | ------ | ------- | -------- | | leagueId | ID of a H2H league | number | - | true | | options.pageStandings | Page number for standings | number | 1 | true | | options.pageNewEntries | Page number for new entries | number | 1 | true |

import { fetchH2HLeagueStandings } from 'fpl-api'

const leagueId = 1
const data = await fetchH2HLeagueStandings(leagueId)

fetchClassicLeague

Get H2H league standings page.

| param | description | type | default | required | | ---------------------- | --------------------------- | ------ | ------- | -------- | | leagueId | ID of a classic league | number | - | true | | options.pageStandings | Page number for standings | number | 1 | true | | options.pageNewEntries | Page number for new entries | number | 1 | true | | options.phase | Phase to show | number | 1 | true |

import { fetchClassicLeague } from 'fpl-api'

const leagueId = 1
const data = await fetchClassicLeague(leagueId)