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

open-fpl

v0.0.2

Published

This is a module for [Premier League](https://www.premierleague.com) data which are mostly used for [Fantasy Premier League (FPL)](https://fantasy.premierleague.com). This module returns JSON data which comes from official Premier League API in a more org

Downloads

2

Readme

Open FPL

Open FPL is an npm package for Premier League data which are mostly used for Fantasy Premier League (FPL). This package returns JSON data which comes from official Premier League API in a more organized and more readable format.

Installation

npm install open-fpl

Getting Started

List of functions:

###GetCurrentGameWeek( callback ) Description: Returns a JSON object containing the Gameweek ID and all the match fixtures with team names for the current Gameweek inside the callback function.

const {gameweek} =  require('open-fpl');
gameweek.GetCurrentGameWeek((err, data) => {
        if(err){
            console.log(err);
            return;
        }
        console.log(data);
    });

Returned Data :

{
"gameweek": 24,
"fixture": [
        {
            "id": 231,
            "kickoff_time_formatted": "29 Jan 19:45",
            "started": true,
            "event_day": 1,
            "deadline_time": "2019-01-29T18:45:00Z",
            "deadline_time_formatted": "29 Jan 18:45",
            "stats": [ ],
            "team_h_difficulty": 2,
            "team_a_difficulty": 4,
            "code": 987823,
            "kickoff_time": "2019-01-29T19:45:00Z",
            "team_h_score": 2,
            "team_a_score": 1,
            "finished": true,
            "minutes": 90,
            "provisional_start_time": false,
            "finished_provisional": true,
            "event": 24,
            "team_a": {
                "id": 5,
                "name": "Cardiff"
            },
            "team_h": {
                "id": 1,
                "name": "Arsenal"
            }
        },
        .,
        .,
        .
    ]
}

###GetGameWeekById( id, callback ) Description : Returns a JSON object containing the Gameweek ID and all the match fixtures with team names for the given Gameweek ID in the callback function.

const {gameweek} =  require('open-fpl');

// here 20 is the id of the gameweek 
gameweek.GetGameWeekById(20, (err, data) => {
        if(err){
            console.log(err);
            return;
        }
        console.log(data);
    });

Return Response Example (JSON): This is an example for Gameweek 20.

{
"gameweek": "20",
"fixture": [
        {
            "id": 191,
            "kickoff_time_formatted": "29 Dec 15:00",
            "started": true,
            "event_day": 1,
            "deadline_time": "2018-12-29T14:00:00Z",
            "deadline_time_formatted": "29 Dec 14:00",
            "stats": [],
            "team_h_difficulty": 3,
            "team_a_difficulty": 3,
            "code": 987782,
            "kickoff_time": "2018-12-29T15:00:00Z",
            "team_h_score": 1,
            "team_a_score": 0,
            "finished": true,
            "minutes": 90,
            "provisional_start_time": false,
            "finished_provisional": true,
            "event": 20,
            "team_a": {
                "id": 8,
                "name": "Everton"
            },
            "team_h": {
                "id": 3,
                "name": "Brighton"
            }
        },
       .,
       .,
       .
    ]
}

###GetAllTeams( callback ) Description : Returns a JSON object containing an array of all teams and their details in the callback function.

const {teams} =  require('open-fpl');

teams.GetAllTeams((err, data) => {
        if(err){
            console.log(err);
            return;
        }
        console.log(data);
        res.send(data);
    });

Returned Data :

[
    {
        "id": 1,
        "current_event_fixture": [
            {
                "is_home": false,
                "day": 9,
                "event_day": 1,
                "month": 2,
                "id": 254,
                "opponent": 10
            }
        ],
        "next_event_fixture": [
            {
                "is_home": true,
                "day": 24,
                "event_day": 3,
                "month": 2,
                "id": 261,
                "opponent": 16
            }
        ],
        "name": "Arsenal",
        "code": 3,
        "short_name": "ARS",
        "unavailable": false,
        "strength": 4,
        "position": 0,
        "played": 0,
        "win": 0,
        "loss": 0,
        "draw": 0,
        "points": 0,
        "form": null,
        "link_url": "",
        "strength_overall_home": 1290,
        "strength_overall_away": 1330,
        "strength_attack_home": 1240,
        "strength_attack_away": 1270,
        "strength_defence_home": 1310,
        "strength_defence_away": 1340,
        "team_division": 1
    },
    .,
    .,
    .
    
]

###GetTeamById( id, callback ) Description : Returns a JSON object containing the team details for the given team ID in the callback function.

const {teams} =  require('open-fpl');
// here 1 is the team id
teams.GetTeamById( 1 , (err, data) => {
        if(err){
            console.log(err);
            return;
        }
        console.log(data);
    });

Return Response Example (JSON): This is an example for team with id : 1.

{
        "id": 1,
        "current_event_fixture": [
            {
                "is_home": false,
                "day": 9,
                "event_day": 1,
                "month": 2,
                "id": 254,
                "opponent": 10
            }
        ],
        "next_event_fixture": [
            {
                "is_home": true,
                "day": 24,
                "event_day": 3,
                "month": 2,
                "id": 261,
                "opponent": 16
            }
        ],
        "name": "Arsenal",
        "code": 3,
        "short_name": "ARS",
        "unavailable": false,
        "strength": 4,
        "position": 0,
        "played": 0,
        "win": 0,
        "loss": 0,
        "draw": 0,
        "points": 0,
        "form": null,
        "link_url": "",
        "strength_overall_home": 1290,
        "strength_overall_away": 1330,
        "strength_attack_home": 1240,
        "strength_attack_away": 1270,
        "strength_defence_home": 1310,
        "strength_defence_away": 1340,
        "team_division": 1
    }

###GetTeamByName( name, callback ) Description : Returns a JSON object containing the team details for the given team name in the callback function.

const {teams} =  require('open-fpl');
// here 1 is the team id
teams.GetTeamByName( 'Arsenal' , (err, data) => {
        if(err){
            console.log(err);
            return;
        }
        console.log(data);
    });

Return Response Example (JSON): This is an example for team 'Arsenal'.

{
        "id": 1,
        "current_event_fixture": [
            {
                "is_home": false,
                "day": 9,
                "event_day": 1,
                "month": 2,
                "id": 254,
                "opponent": 10
            }
        ],
        "next_event_fixture": [
            {
                "is_home": true,
                "day": 24,
                "event_day": 3,
                "month": 2,
                "id": 261,
                "opponent": 16
            }
        ],
        "name": "Arsenal",
        "code": 3,
        "short_name": "ARS",
        "unavailable": false,
        "strength": 4,
        "position": 0,
        "played": 0,
        "win": 0,
        "loss": 0,
        "draw": 0,
        "points": 0,
        "form": null,
        "link_url": "",
        "strength_overall_home": 1290,
        "strength_overall_away": 1330,
        "strength_attack_home": 1240,
        "strength_attack_away": 1270,
        "strength_defence_home": 1310,
        "strength_defence_away": 1340,
        "team_division": 1
    }
  • This documentation will be updated soon with more functions. Cheers!