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

Help with attributes for outputting data and required parameters for endpoints #31

Closed
SpecCRA opened this issue Jan 7, 2019 · 2 comments
Labels
question Inquiry from community

Comments

@SpecCRA
Copy link

SpecCRA commented Jan 7, 2019

Hi! iI wanted to say thank you for making this API first of all. I've seen and gotten some great data from it so far.

I have a few issues with everything, and I don't know if I'm just missing bits in the documentation.

For example, here's one snippet of code I have for ShotChartDetail:

initial_data = ShotChartDetail(player_id = ghay_id, # id of player season_nullable = current_year, # which year team_id=0, # team id used if multiple players found context_measure_simple='FGA')

Now I know I completed the required parameters, but it looks inconsistent with what's written in the documentation for that endpoint.

In the documentation, the required parameters are then listed as such:

"required_parameters": [ "ContextMeasure", "DateFrom", "DateTo", "GameID", "GameSegment", "LastNGames", "Location", "Month", "OpponentTeamID", "Outcome", "Period", "PlayerID", "PlayerPosition", "RookieYear", "SeasonSegment", "SeasonType", "TeamID", "VsConference", "VsDivision" ],

So is there a more complete way for me to see what parameters are required for each endpoint?

Furthermore, I see people using the get_data_frames() attribute on the objects afterwards to extract the data into a pandas dataframe which is great. I noticed there are plenty of other attributes when using PyCharm. For ShotChartDetails, it outputs two dataframes, so I am confused as to what each endpoint does output and what attributes are available for use.

Is there documentation or another guide to show the available attributes and its associated outputs?

Thanks!

Ben

@swar
Copy link
Owner

swar commented Jan 8, 2019

@SpecCRA

I tried to explain here (Endpoint Analysis Format.md) that required parameters are parameters that are required to be passed, but can also be nullable. Meaning you must pass them in as parameters, but they don't need any values.

Let's take the (CommonPlayoffSeries Endpoint](https://github.com/swar/nba_api/blob/master/docs/nba_api/stats/endpoints/commonplayoffseries.md) as an example.

Here is the Parameters chart:

API Parameter Name Python Parameter Variable Pattern Required Nullable
Season season ^\d{4}-\d{2}$ Y
SeriesID series_id_nullable Y
LeagueID league_id_nullable (00)|(20)|(10) Y Y

Here is a valid URL to visit the Endpoint: https://stats.nba.com/stats/commonplayoffseries?LeagueID=&Season=2017-18&SeriesID=

Both LeagueID and SeriesID are nullable. Meaning they do not need any values passed as in the above example. SeriesID is not a required parameter so the following url is also valid.
https://stats.nba.com/stats/commonplayoffseries?LeagueID=&Season=2017-18

Since LeagueID is required, the following urls would throw errors despite it being a nullable parameter.
https://stats.nba.com/stats/commonplayoffseries?Season=2017-18&SeriesID=
https://stats.nba.com/stats/commonplayoffseries?Season=2017-18

Hopefully that clears up any confusion you might have on that. What you have made me realize is that I do not list the default values passed to parameters in the endpoint documentation. In order to see the default values, you need to manually click on each API Parameter name to see the assigned default. These would be the values required for you to input to get the Python API call to work.

A temporary solution is to look at the Python file (linked at the top of each documentation page) to see the values passed into the endpoints.
Here is nba_api/stats/endpoints/shotchartdetail.py

To answer your last paragraph, sometimes Endpoints return many different sets of data which is what I defined as a data set in the package. Here are the available data sets for ShotChartDetail

Feel free to re-ask a question if I missed it.

@swar swar added the question Inquiry from community label Jan 8, 2019
@SpecCRA
Copy link
Author

SpecCRA commented Jan 8, 2019

I was looking for this page and just hadn't stumbled across it yet.

Thank you for taking the time to answer my question in such detail! I think I was most confused about which values have a default value and how it affected the output after getting several errors about what's required and what wasn't.

@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

2 participants