Skip to content

jharrilim/balldontlie-client

Repository files navigation

balldontlie-client

Build Status NPM Badge NPM Downloads

Javascript client for Balldontlie.

API Docs for this client can be found here.

Rasheed Wallace - Ball Dont Lie

API Implementation Status

API Status
Players
Teams
Games
Stats
Season Averages

Install

npm i @jharrilim/balldontlie-client

Usage

This library uses async generators for handling pagination. You may use this in conjunction with for-await-of to make multiple API requests. You may also request for one page at a time by awaiting .next().

Axios is used interally, and axios configuration options may be passed into .v1() if needed.

Warning: This API is rate limited. You may only make up to 60 requests per minute.

Example with for-await-of

import { BallDontLie } from '@jharrilim/balldontlie-client';

void async function main() {
    const v1Client = BallDontLie.v1();
    for await(const teams of v1Client.teams(0)) {
        // paginate through all the teams
        for(const team of teams) {
            console.log(team.full_name);
        }
    }
}().catch(console.error);

Example with .next()

import { BallDontLie } from '@jharrilim/balldontlie-client';

void async function main() {
    const v1Client = BallDontLie.v1();
    const teamGenerator = v1Client.teams(0, 10); // starting from 0, 10 per page
    
    const teams1 = (await teamGenerator.next()).value; // get the first 10 teams
    teams1.forEach(team => console.log(team.full_name));

    const teams2 = (await teamGenerator.next()).value; // get the next 10 teams after the first 10
    teams2.forEach(team => console.log(team.full_name));

}().catch(console.error);

More examples can be found in the tests.

About

Javascript client for retrieving NBA stats with the balldontlie API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •