Package Exports
- @jharrilim/balldontlie-client
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jharrilim/balldontlie-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
balldontlie-client
Javascript client for Balldontlie.
API Docs for this client can be found here.
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.