Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request failing #38

Closed
shaunwhyte opened this issue Jan 19, 2019 · 6 comments
Closed

Request failing #38

shaunwhyte opened this issue Jan 19, 2019 · 6 comments
Labels
question Inquiry from community

Comments

@shaunwhyte
Copy link

https://stats.nba.com/stats/boxscoreadvancedv2?EndPeriod=1&EndRange=0&GameID=0021700807&RangeType=0&StartPeriod=1&StartRange=0

if i put a request like the above one in google chrome i get a response if i put into Postman or python i get nothing?

@shaunwhyte
Copy link
Author

Seems like none of the boxscores work however i can get some of the others

@shaunwhyte
Copy link
Author

shaunwhyte commented Jan 19, 2019

Do i need special headers.
Update added the chrome headers to postman and it worked! Now python...

@swar
Copy link
Owner

swar commented Jan 19, 2019

@shaun2416

That link is working for me. You may need special headers to mimic your browser, because I do not know if headers are specific to a certain region. Someone from France had luck by changing the headers.

@rsforbes
Copy link
Collaborator

rsforbes commented Jan 20, 2019

@shaun2416 - Try the following...

#Get the Pacers team_id
from nba_api.stats.static import teams
nba_teams = teams.get_teams()

#Select the dictionary for the Pacers, which contains their team ID
pacers = [team for team in nba_teams if team['abbreviation'] == 'IND'][0]
pacers_id = pacers['id']

#Query for the last regular season game where the Pacers were playing
from nba_api.stats.endpoints import leaguegamefinder
from nba_api.stats.library.parameters import Season
from nba_api.stats.library.parameters import SeasonType

gamefinder = leaguegamefinder.LeagueGameFinder(team_id_nullable=pacers_id,
                            season_nullable=Season.default,
                            season_type_nullable=SeasonType.regular)  

games_dict = gamefinder.get_normalized_dict()
games = games_dict['LeagueGameFinderResults']
game = games[0]
game_id = game['GAME_ID']

#boxscoreadvancedv2
from nba_api.stats.endpoints import boxscoreadvancedv2
boxscore = boxscoreadvancedv2.BoxScoreAdvancedV2(game_id)
boxscore.get_normalized_json()

@shaunwhyte
Copy link
Author

Yeah i think it might be a region thing cos I had some headers that worked then put my vpn on then it stopped Thanks

@swar swar added the question Inquiry from community label Jan 22, 2019
@swar
Copy link
Owner

swar commented Feb 18, 2019

Headers may be specific to region. If you are seeing issues with requests, you should try changing your headers. This especially applies if you are not from the US.

@swar swar closed this as completed Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Inquiry from community
Projects
None yet
Development

No branches or pull requests

3 participants