All Projects → mkreiser → Espn Fantasy Football Api

mkreiser / Espn Fantasy Football Api

Licence: lgpl-3.0
Connect to ESPN's fantasy football API via this JS API client for web and NodeJS. Available as an npm package.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Espn Fantasy Football Api

Sdk Js
Directus JS SDK — JavaScript Software Development Kit for Node and Browser
Stars: ✭ 117 (-37.77%)
Mutual labels:  api, api-client
Thehive4py
Python API Client for TheHive
Stars: ✭ 143 (-23.94%)
Mutual labels:  api, api-client
Tik4net
Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Stars: ✭ 118 (-37.23%)
Mutual labels:  api, api-client
Douyin Api
抖音API、抖音数据、抖音直播数据、抖音直播Api、抖音视频Api、抖音爬虫、抖音去水印、抖音视频下载、抖音视频解析、抖音直播监控、抖音数据采集
Stars: ✭ 112 (-40.43%)
Mutual labels:  api, api-client
Dialogflow
Unofficial php sdk for Dialogflow
Stars: ✭ 165 (-12.23%)
Mutual labels:  api, api-client
Pixiv Api Client
Promise based Pixiv API client for node.js and react native
Stars: ✭ 114 (-39.36%)
Mutual labels:  api, api-client
Laravel Api Explorer
API explorer for laravel applications
Stars: ✭ 138 (-26.6%)
Mutual labels:  api, api-client
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (-58.51%)
Mutual labels:  api, api-client
Mobx Rest
REST conventions for Mobx
Stars: ✭ 164 (-12.77%)
Mutual labels:  api, api-client
Espn Api
ESPN Fantasy API! (Football, Basketball)
Stars: ✭ 155 (-17.55%)
Mutual labels:  api, football
Laqul
A complete starter kit that allows you create amazing apps that look native thanks to the Quasar Framework. Powered by an API developed in Laravel Framework using the easy GraphQL queries language. And ready to use the Google Firebase features.
Stars: ✭ 110 (-41.49%)
Mutual labels:  api, api-client
Js Client
A Open-API derived JS + Node.js API client for Netlify
Stars: ✭ 170 (-9.57%)
Mutual labels:  api, api-client
Rapidql
Query multiple APIs and DBs and join them in a single query
Stars: ✭ 91 (-51.6%)
Mutual labels:  api, api-client
Coinbase Pro Node
Coinbase Pro API written in TypeScript and covered by tests.
Stars: ✭ 116 (-38.3%)
Mutual labels:  api, api-client
Google Searchconsole
A wrapper for the Google Search Console API.
Stars: ✭ 83 (-55.85%)
Mutual labels:  api, api-client
Anyapi
AnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.
Stars: ✭ 126 (-32.98%)
Mutual labels:  api, api-client
Igdb
Go client for the Internet Game Database API
Stars: ✭ 65 (-65.43%)
Mutual labels:  api, api-client
Openvulnapi
Documentation and Tools for Cisco's PSIRT openVuln API
Stars: ✭ 73 (-61.17%)
Mutual labels:  api, api-client
World Cup.json
Free open public domain football data for the world cups in JSON incl. Russia 2018 and more - No API key required ;-)
Stars: ✭ 152 (-19.15%)
Mutual labels:  api, football
Coingecko Api
A Node.js wrapper for the CoinGecko API with no dependencies.
Stars: ✭ 159 (-15.43%)
Mutual labels:  api, api-client

ESPN Fantasy Football API

npm node Blazing Fast

Build Status Maintainability Test Coverage dependencies Status devDependencies Status Known Vulnerabilities

A Javascript API client for both web and NodeJS that connects to the updated v3 ESPN fantasy football API. Available as an npm package.

Features

  • Supports pulling data from ESPN.
  • Private league support (NodeJS version only, see Important Notes).
  • Highly documented.
  • Built for speed and efficiency with caching support.
  • Built for extensibility by using ES6 classes.

Documentation Reference

Hosted documentation available at http://espn-fantasy-football-api.s3-website.us-east-2.amazonaws.com/.

Installation

npm install --save espn-fantasy-football-api

There are four files exported in the package:

  • web.js - Production file built for web environments (main/default file).
  • node.js - Production file built for NodeJS environments.
  • web-dev.js - Same as web, but not minified/obfused to make debugging/developing easier.
  • node-dev.js - Same as node, but not minified/obfused to make debugging/developing easier.

Important Notes

ESPN Databases and Data Storage

This project simply retrieves data from ESPN and formats the responses in an easy to read and use format. ESPN is still responsible for maintaining and providing the data. Recently, many have noticed league data disappearing from previous years, including in other ESPN fantasy sports. This appears to be a result of ESPN deleting this data. While some data exists before 2017 (as of Feb. 1, 2019), some data (such as boxscores) is not longer available.

ESPN API Changes

Since this project wraps the ESPN API, any breaking changes to the ESPN API will break this project. This occurred in February 2019 when ESPN migrated from their v2 API to a new v3 API (the original version of this project was completed in Janurary 2019). This project has been updated to consume ESPN's v3 API.

Private Leagues

Private leagues currently only work with the NodeJS version of this project, due to limitations in setting headers in browsers.

How to use

ESPN API Conventions

  • leagueId is the id for your league.

    • Example: 387659
  • seasonId matches the year in which the season was played.

    • Example: 2018
  • matchupPeriod refers to an entire match-up, including if the match-up lasts multiple weeks (not rare in playoff settings for smaller leagues).

    • Example: 3 refers to the third matchup in your league.
  • scoringPeriod refers to a single NFL week. Since most matchups are 1 week long, the scoringPeriod will typically match the matchupPeriod. However, for multi-week matchups, scoringPeriod allows one to get information about a specific week in the match-up (useful in multi-week playoff match-up).

    • Example: 3 refers to the third week of the NFL season.
    • Note: A scoringPeriodId of 0 refers to the preseason before any games are played. A scoringPeriodId of 18 refers to the end of the season.
  • If both a matchupPeriod and a scoringPeriod are used, the scoringPeriod takes precedence.

Importing ESPN Fantasy Football API

// ES6
import { ... } from 'espn-fantasy-football-api'; // web
import { ... } from 'espn-fantasy-football-api/node'; // node
import { ... } from 'espn-fantasy-football-api/web-dev'; // web development build
import { ... } from 'espn-fantasy-football-api/node-dev'; // node development build

// ES5
const { ... } = require('espn-fantasy-football-api'); // web
const { ... } = require('espn-fantasy-football-api/node'); // node
const { ... } = require('espn-fantasy-football-api/web-dev'); // web development build
const { ... } = require('espn-fantasy-football-api/node-dev'); // node development build

How to Get Data

Creating a Client

This will allow you to call the various methods on the Client class to grab data for the passed league. For working with multiple leagues, create multiple Client instances.

import { Client } from 'espn-fantasy-football-api';
const myClient = new Client({ leagueId: 432132 });

Working with Private Leagues

You'll need two cookies from ESPN: espn_s2 and SWID. These are found at "Application > Cookies > espn.com" in the Chrome DevTools when on espn.com.

Note: As specified before, this functionality only works in NodeJS.

myClient.setCookies({ espnS2: 'YOUR_ESPN_S2', SWID: 'YOUR_SWID' });

Built With

axios - Promise based HTTP client.

babel + webpack - Compiles and bundles ES6 and next-gen Javascript to browser-compatible Javascript.

eslint - Fast code linting to maintain good style and code patterns.

jest - Powerful and fast testing platform.

jsdoc - Generated code documentation.

lodash - Utility library.

Versioning

This project uses Semantic Versioning. Until the 1.0.0 version is published, all major changes will be published with a minor version bump.

License

This project is licensed under LGPL-3.0 (see LICENSE for details). Essentially, don't take this project and close source it.

This is my first time writing OSS and picking a license. Feel free to reach out with questions and/or concerns.

npm scripts

Script Description
build Builds the module.
build:docs Builds the docs.
clean Runs all clean scripts.
clean:dist Removes the dist folder.
clean:docs Removes the docs folder.
ci Runs continuous integration tasks. Currently runs lint, unit and integration tests, and build.
lint Ensures code style is correct.
serve:docs Builds and serves docs. Defaults to port 8080.
test Starts a jest test runner with access to all tests. Pass --watch to keep jest alive and watching for changes. Pass a string as a file inclusion pattern.
test:all Runs the unit tests then the integration tests.
test:integration Runs the integration tests.
test:unit Runs the unit tests.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].