Javascript client for Balldontlie.
API Docs for this client can be found here.
API | Status |
---|---|
Players | ✅ |
Teams | ✅ |
Games | ✅ |
Stats | ✅ |
Season Averages | ✅ |
npm i @jharrilim/balldontlie-client
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.
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);
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.