bttmly / nba

Node.js client for nba.com API endpoints

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Timeouts

bialesdaniel opened this issue · comments

I am getting a lot of timeouts

message: 'request to https://stats.nba.com/stats/leaguedashplayerstats?College=&Conference=&Country=&DateFrom=&DateTo=&Division=&DraftPick=&DraftYear=&GameScope
=&GameSegment=&Height=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&Playe
rExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=&SeasonSegment=&SeasonType=Regular%20Season&ShotClockRange=&StarterBench=&TeamID=0&VsConference=&VsDivision
=&Weight= failed, reason: read ETIMEDOUT',

Is there some throttling or quotas on the nba endpoints? or is there some way to get around this?

are you making requests from your local machine or from a cloud instance? nba.com blocks ip addresses of known cloud providers by letting requests hang and time out.

they also do rate limiting.

I'm running it locally. I'm probably hitting the rate limit. Any chance you know what that is?

No, I think it varies by endpoint. But if I need to run a lot of requests I just try to do 1 per second then walk away and wait for it to finish. something more or less like this

const delay = ms => new Promise(r => setTimeout(r, ms));

const playerInfo = [];
for (const player of players) {
  playerInfo.push(await nba.playerInfo({ PlayerID: player.PlayerID });
  await delay(1000);
}