Search code examples
nba-api

Fetching data from nba.com/stats/transactions/


Is there a method in the nba-api package which allows querying the endpoint for data regarding transactions between teams (https://www.nba.com/stats/transactions/)?


Solution

  • I didn't look, but no need for that package. Just get that data directly:

    import pandas as pd  
    import requests
    
    url = 'https://www.nba.com/stats/js/data/playermovement/NBA_Player_Movement.json'
    jsonData = requests.get(url).json()
    
    df = pd.DataFrame(jsonData['NBA_Player_Movement']['rows'])
    

    Output:

    print(df)
         Transaction_Type     TRANSACTION_DATE  ... Additional_Sort        GroupSort
    0             Signing  2021-04-21T00:00:00  ...             0.0  Signing 1039411
    1             Signing  2021-04-21T00:00:00  ...             0.0  Signing 1039412
    2             Signing  2021-04-21T00:00:00  ...             0.0  Signing 1039413
    3             Signing  2021-04-21T00:00:00  ...             0.0  Signing 1039414
    4             Signing  2021-04-20T00:00:00  ...             0.0  Signing 1039383
                  ...                  ...  ...             ...              ...
    4581          Signing  2015-07-02T00:00:00  ...             0.0   Signing 944820
    4582          Signing  2015-07-02T00:00:00  ...             0.0   Signing 944876
    4583          Signing  2015-07-02T00:00:00  ...             0.0   Signing 944877
    4584          Signing  2015-07-02T00:00:00  ...             0.0   Signing 944878
    4585          Signing  2015-07-01T00:00:00  ...             0.0   Signing 944801
    
    [4586 rows x 9 columns]