ynnadkrap / balldontlie

NBA API
http://www.balldontlie.io
225 stars 19 forks source link

Stats for multiple players #11

Closed cailborg closed 5 years ago

cailborg commented 5 years ago

More of a question than an issue, but is there a reason you set it up to have multiple players joined by & and not just within one single player_ids array? What is the empty array after each player_id for? Can work around the implementation but was just curious!

Current api/v1/season_averages?season=2018&player_ids[]=1&player_ids[]=2

Example api/v1/season_averages?season=2018&player_ids=[1, 2]

jharrilim commented 5 years ago

I think that might just be how ruby handles query params: https://guides.rubyonrails.org/action_controller_overview.html#hash-and-array-parameters

If you'd like to see how I handled this, check here: https://github.com/jharrilim/balldontlie-client/blob/master/src/api/v1/index.ts#L11

ynnadkrap commented 5 years ago

It depends on the framework. As jharrilim said above, rails expects foo[]=1&foo[]=2. Here's some good info: https://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string

cailborg commented 5 years ago

Excellent, thanks for the info guys, will dive into rails a bit more!