nba_api | An API Client package to access the APIs for NBA.com | REST library

 by   swar Python Version: 1.4.1 License: MIT

kandi X-RAY | nba_api Summary

kandi X-RAY | nba_api Summary

nba_api is a Python library typically used in Web Services, REST applications. nba_api has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However nba_api build file is not available. You can install using 'pip install nba_api' or download it from GitHub, PyPI.

nba_api is an API Client for www.nba.com. This package is meant to make the API Endpoints more accessible and to provide extensive documentation. The APIs on www.nba.com are largely undocumented and change frequently. Please feel free to contribute and have an open discussion regarding improvements and additional APIs to be mapped.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              nba_api has a medium active ecosystem.
              It has 1727 star(s) with 443 fork(s). There are 84 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 45 open issues and 197 have been closed. On average issues are closed in 211 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of nba_api is 1.4.1

            kandi-Quality Quality

              nba_api has 0 bugs and 0 code smells.

            kandi-Security Security

              nba_api has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              nba_api code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              nba_api is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              nba_api releases are available to install and integrate.
              Deployable package is available in PyPI.
              nba_api has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions, examples and code snippets are available.
              nba_api saves you 10317 person hours of effort in developing the same functionality from scratch.
              It has 20977 lines of code, 518 functions and 178 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed nba_api and discovered the below as its top functions. This is intended to give you an instant insight into nba_api implemented functionality, and help decide if they suit your requirements.
            • Analyze endpoint_list and save it to file
            • Analyze an endpoint
            • Removes invalid parameters from the given endpoint
            • Test for invalid parameters
            • Generate all endpoint documentation
            • Get the python variable name
            • Get the documentation for an endpoint
            • Builds a URL query string from a list of parameters
            • Sends the request
            • Get the API request
            • Sends an API request
            • Find team name by ID
            • Performs a GET request
            • Perform a GET request
            • Send a request to Nba
            • Sends a request
            • Find player by id
            • Find a team by its abbreviation
            • Make a request to the API
            • Performs a GET request
            • Get the API request
            • Request API response
            • Get API request
            • Make a GET request
            • Sends an API request
            • Request the API
            Get all kandi verified functions for this library.

            nba_api Key Features

            No Key Features are available at this moment for nba_api.

            nba_api Examples and Code Snippets

            Python - Trying to Save File into Docker Volume
            Pythondot img1Lines of Code : 28dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            os.makedirs(PATH, exist_ok=True)
            
            import os
            import urllib.request
            import json
            import logging
            
            BASE_URL = 'https://cdn.nba.com/static/json/liveData/playbyplay/playbyplay_'
            PATH = os.path.join(os.getcwd(), 'nba-matche
            How to combine every 2 rows into 1 row
            Pythondot img2Lines of Code : 37dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # source datafrome
            year = '2020'
            df = pd.read_excel('https://www.sportsbookreviewsonline.com/scoresoddsarchives/mlb/mlb%20odds%202011.xlsx')
            df = df.dropna(how="all").copy()
            
            df["Date"] = df["Date"].astype(int)  # To handle excel float typ
            Can only pull 2020 team roster using commonteamroster endpoint
            Pythondot img3Lines of Code : 13dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # get teams from the reg season 2021-22
            teamfinder = commonteamroster.CommonTeamRoster(season='2021-22',
                                                          team_id='1610612738',
                                                          league_id_nullable='
            Traceback error when I am attempting to grab all box scores
            Pythondot img4Lines of Code : 5dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            game_ids = games['GAME_ID'].unique().tolist()
            for game_id in game_ids:
                player_stats_data = boxscoreadvancedv2.BoxScoreAdvancedV2(game_id=game_id, headers=headers, timeout=100)
                # Use the stats...
            
            How to get nba shot chart data correctly?
            Pythondot img5Lines of Code : 14dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            response = shotchartdetail.ShotChartDetail(
                team_id=0,
                player_id=0,
                season_nullable='2001-02',
                context_measure_simple = 'FGA', #<-- Default is 'PTS' and will only return made shots, but we want all shot attempts
                seas
            Value Error Mismatch While Converting Using Pandas
            Pythondot img6Lines of Code : 6dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            df = pd.DataFrame(rows)
            try:
                df.columns = headers
            except:
                pass
            
            Collecting specific player info from NBA API
            Pythondot img7Lines of Code : 8dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            {
                'CommonPlayerInfo': [ ... ],
                'PlayerHeadlineStats': [ ... ],
                'AvailableSeasons': [ ...]
            }
            
            player_info = player_info.get('CommonPlayerInfo')[0]
            

            Community Discussions

            QUESTION

            Webscrape NBA stats nba_api endpoints
            Asked 2022-Mar-21 at 10:25

            I am trying to scrape the data from NBA stats, specifically the team's boxscore. I am looking for the nba_api endpoint for this page so that i can scrape the data.

            How can I find the endpoint?

            ...

            ANSWER

            Answered 2022-Mar-20 at 15:59

            I'm not a huge sports fan, but this seems like it: A free NBA Boxscore API You could attempt to isolate the CSS, JS and HTML segments from the site.

            It is in the source of a div.

            Source https://stackoverflow.com/questions/71548181

            QUESTION

            Can only pull 2020 team roster using commonteamroster endpoint
            Asked 2021-Sep-19 at 08:06

            I'm currently attempting to grab the latest team rosters from the NBA using the commonteamroster endpoint, but it seems like whatever season_id I enter, it only returns the 2020 rosters.

            The roster I am looking at grabbing can be found here: https://www.nba.com/stats/team/1610612738/?Season=2021-22

            My code

            ...

            ANSWER

            Answered 2021-Sep-19 at 08:06

            It works fine. Did you not look at the output from:

            Source https://stackoverflow.com/questions/69201081

            QUESTION

            Traceback error when I am attempting to grab all box scores
            Asked 2021-Sep-11 at 15:44
            import pandas as pd
            import requests
            
            headers  = {
                'Connection': 'keep-alive',
                'Accept': 'application/json, text/plain, */*',
                'x-nba-stats-token': 'true',
                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
                'x-nba-stats-origin': 'stats',
                'Sec-Fetch-Site': 'same-origin',
                'Sec-Fetch-Mode': 'cors',
                'Referer': 'https://stats.nba.com/',
                'Accept-Encoding': 'gzip, deflate, br',
                'Accept-Language': 'en-US,en;q=0.9',
            }
            
            from nba_api.stats.endpoints import leaguegamefinder
            
            # get game logs from the reg season
            gamefinder = leaguegamefinder.LeagueGameFinder(season_nullable='2020-21',
                                                           league_id_nullable='00',
                                                           season_type_nullable='Regular Season')
            games = gamefinder.get_data_frames()[0]
            
            # get a list of distinct game ids
            game_id = games['GAME_ID'].unique().tolist()
            
            player_stats_data = boxscoreadvancedv2.BoxScoreAdvancedV2(game_id=game_id, headers=headers, timeout=100)
            stats_df = player_stats_data.get_data_frames()[0]
            stats_df.head()
            
            ...

            ANSWER

            Answered 2021-Sep-11 at 06:09

            Looking at the API documentation, it takes a single game id.

            One approach could be to loop over the game ids you have:

            Source https://stackoverflow.com/questions/69140470

            QUESTION

            Being able to scrape a website's data for NBA daily leaders. But problem with MaxRetryError
            Asked 2021-Apr-30 at 07:06

            I'm trying to create a program for class, and am struggling, it was somewhat working at one point, but I have a feeling I may have blacklisted myself, cause I'm getting a MaxRetryError when executing the code.

            Max retries exceeded with url: /session/535f3b31b6b76ca10ea210f69675563e/url (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'

            I was wondering if my code will work on someone else's machine haha :D

            So the jist of my code is that the user will be asked a date in the format yyyy-mm-dd then uses that date to find all the box scores associated with the date.

            This is the function giving me grief.

            ...

            ANSWER

            Answered 2021-Apr-30 at 07:06

            There is an api. Just use the gameid and then you can parse the json however you wish. For example:

            Source https://stackoverflow.com/questions/67321920

            QUESTION

            How to get nba shot chart data correctly?
            Asked 2021-Jan-08 at 13:46

            I want to get data from nba site to create shot chart. I get it from this site https://datavizardry.com/2020/01/28/nba-shot-charts-part-1/?fbclid=IwAR3BheHQkSAmCJRr_z7ux1ygbspLjLdrvTRjWAVHOrr2BPvVh7jsIos_e9w and my code looks like this:

            ...

            ANSWER

            Answered 2021-Jan-08 at 13:46

            The package by default (likely its been updated since the article) is set to only return shots where a point was scored, so you need to change that parameter to not be points, but rather field goal attempts, since that will return made and missed shots:

            Source https://stackoverflow.com/questions/65627725

            QUESTION

            How do I convert NBA-API List to DataFrame
            Asked 2020-Nov-13 at 23:54

            Having an issue converting NBA-API object to a DataFrame. What I get is a list of the dataframe. How do I pull the DataFrame out the list or skip the list and create the DataFrame.

            ...

            ANSWER

            Answered 2020-Nov-13 at 22:40

            QUESTION

            Value Error Mismatch While Converting Using Pandas
            Asked 2020-Oct-05 at 14:49

            here is the mismatch error I keep getting. I'm inputting "202710".

            ...

            ANSWER

            Answered 2020-Oct-05 at 14:49

            This is because your df is empty for ID 202710. Exception handling will resolve the issue here-

            Source https://stackoverflow.com/questions/64209997

            QUESTION

            Traceback when using Pandas to convert to Json Format
            Asked 2020-Sep-29 at 13:11

            I recently have been trying to use the NBA API to pull shot chart data. I'll link the documentation for the specific function I'm using here.

            I keep getting a traceback as follows:

            ...

            ANSWER

            Answered 2020-Sep-29 at 13:11

            You are getting this because the filename has no extension. Pandas will use the extension (like xlsx or xls) of the filename (if you're not giving it an ExcelWriter) to understand the right lib to use for this format. Just try this with something like df.to_excel('filename.xlsx', index=False) and see how goes.

            Source https://stackoverflow.com/questions/64120192

            QUESTION

            Problem with resetting for loop when reading over csv files
            Asked 2020-Sep-02 at 20:43

            In my code for an NBA simulation which allows the user to select 2 teams from the same or different seasons. If the user selects both teams from the 2019-20 season then the team 1 point array and opponent 1 point array is filled but the team 2 and opponent 2 arrays are empty. Every other combination of seasons and teams work e.g. team 1 from 2019-20 and team 2 from 2015-16. I'm pretty sure the issue is to do with the for loop in the if statement checking if the season2 is equal to 2019-20.

            ...

            ANSWER

            Answered 2020-Sep-02 at 20:37

            After the first for loop everything in the file has been read, so there's nothing left for the second loop to read. Starting a new for loop doesn't reset the file back to the beginning. You need to seek back to the beginning of the file before trying to read it again.

            Source https://stackoverflow.com/questions/63713124

            QUESTION

            Export a pandas data frame into a csv file ('list' object has no attribute 'to_csv')
            Asked 2020-Aug-21 at 14:09

            Hello I'm trying to export a pandas dataframe in a csv file but I got no clue how to do it. And I got this error 'list' object has no attribute 'to_csv'

            ...

            ANSWER

            Answered 2020-Aug-21 at 14:09

            You have a list of dataframes instead of the dataframe. You can either to save each one of them using .to_csv() method or use pd.concat(player_results, axis=0) to concatenate them and then save it.

            Source https://stackoverflow.com/questions/63524400

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install nba_api

            Required and Optional Packages:.
            requests
            pandas (optional)

            Support

            Please try to avoid sending questions to my personal email that regard researching a solution to your specific problem. I don't mind helping, but the library has been setup with expansive documentation that should be checked first prior to reaching out to me personally. Alternatively, there are other places where you can ask for general advice that has been listed below.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install nba_api

          • CLONE
          • HTTPS

            https://github.com/swar/nba_api.git

          • CLI

            gh repo clone swar/nba_api

          • sshUrl

            git@github.com:swar/nba_api.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link