Basketball documentation

  • Home
  • Basketball documentation

Endpoints

ALL SPORTS API - Basketball API Version 2.0

Welcome to the documentation page of AllSportsAPI.com basketball service. Please find bellow the full list of the methods you can relay on to get real time basketball data helping you build awesome applications.

Countries


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Countries

Returns list of supported countries included in your current subscription plan


Parameters

Parameter Description
met API method name
APIkey Authorization code generated from your allsportsapi account

Request URL


JSON Response

{
    "success": 1,
    "result": [
        {
            "country_key": "227",
            "country_name": "Africa"
        },
        {
            "country_key": "204",
            "country_name": "Argentina"
        },
        {
            "country_key": "212",
            "country_name": "Asia"
        },
        {
            "country_key": "208",
            "country_name": "Australia"
        },
        {
            "country_key": "200",
            "country_name": "Austria"
        },
        {
            "country_key": "235",
            "country_name": "Bahrain"
        },
    ......
  ]
}
                                

PHP call example


$APIkey='!_your_account_APIkey_!';

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Countries&APIkey=$APIkey",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

                                


Leagues


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Leagues

Returns list of supported competitions included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
countryId Country ID - if set only leagues from specific country will be returned (Optional)

Request URL


JSON Response

{
  "success": 1,
  "result": [
    {
        "league_key": "766",
        "league_name": "NBA",
        "country_key": "197",
        "country_name": "USA"
    },
    {
         "league_key": "982",
         "league_name": "BIG3 (3x3)",
         "country_key": "197",
         "country_name": "USA"
     },
     {
         "league_key": "812",
         "league_name": "CBI",
         "country_key": "197",
         "country_name": "USA"
     },
     {
         "league_key": "813",
         "league_name": "CIT",
         "country_key": "197",
         "country_name": "USA"
     },
     {
         "league_key": "892",
         "league_name": "IBL",
         "country_key": "197",
         "country_name": "USA"
     },
     .......
  ]
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;
$countryId = 197;

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Leagues&APIkey=$APIkey&countryId=$countryId",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


Fixtures


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Fixtures

Returns events included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
from Start date (yyyy-mm-dd)
to Stop date (yyyy-mm-dd)
timezone The timezone where you want to receive the data in tz format (exemple: America/New_York). Default timezone: Europe/Berlin (Optional)
countryId Country ID - if set only events from specific country will be returned (Optional)
leagueId League ID - if set events from specific league will be returned (Optional)
matchId Match ID - if set only details from specific match will be returned (Optional)
teamId Team ID - if set only details from specific team will be returned (Optional)

Request URL


JSON Response

{
    "success": 1,
    "result": [
        {
            "event_key": "41223",
            "event_date": "2022-04-21",
            "event_time": "01:00",
            "event_home_team": "Boston Celtics",
            "home_team_key": "7",
            "event_away_team": "Brooklyn Nets",
            "away_team_key": "2",
            "event_final_result": "114 - 107",
            "event_quarter": "",
            "event_status": "Finished",
            "country_name": "USA",
            "league_name": "NBA",
            "league_key": "766",
            "league_round": null,
            "league_season": "2021/2022",
            "event_live": "0",
            "event_home_team_logo": "https://apiv2.allsportsapi.com/logo-basketball/7_boston_celtics.jpg",
            "event_away_team_logo": null,
            "scores": {
                "1stQuarter": [
                    {
                        "score_home": "24",
                        "score_away": "33"
                    }
                ],
                "2ndQuarter": [
                    {
                        "score_home": "31",
                        "score_away": "32"
                    }
                ],
                "3rdQuarter": [
                    {
                        "score_home": "30",
                        "score_away": "25"
                    }
                ],
                "4thQuarter": [
                    {
                        "score_home": "29",
                        "score_away": "17"
                    }
                ]
            },
            "statistics": [
                {
                    "type": "Total Assists",
                    "home": "27",
                    "away": "16"
                },
                {
                    "type": "Total Blocks",
                    "home": "4",
                    "away": "8"
                },
                ........
            ],
            "lineups": {
                "home_team": {
                    "starting_lineups": [
                        {
                            "player": "J. Tatum",
                            "player_id": "2673921644"
                        },
                        {
                            "player": "A. Horford",
                            "player_id": "2646138633"
                        },
                        .......
                    ],
                    "substitutes": [
                       {
                           "player": "G. Williams",
                           "player_id": "4155194651"
                       },
                       {
                           "player": "D. White",
                           "player_id": "1528742162"
                       },
                       ......
                     ],
                 },
                 ......
             },
             "player_statistics": {
                "home_team": [
                    {
                        "player": "J. Tatum",
                        "player_id": "2673921644",
                        "player_assists": "10",
                        "player_blocks": "1",
                        "player_defense_rebounds": "5",
                        "player_field_goals_attempts": "16",
                        "player_field_goals_made": "5",
                        "player_freethrows_goals_attempts": "8",
                        "player_freethrows_goals_made": "7",
                        "player_minutes": "41",
                        "player_offence_rebounds": "1",
                        "player_oncourt": "False",
                        "player_personal_fouls": "4",
                        "player_plus_minus": "+11",
                        "player_position": "SF",
                        "player_points": "19",
                        "player_steals": "0",
                        "player_threepoint_goals_attempts": "5",
                        "player_threepoint_goals_made": "2",
                        "player_total_rebounds": "6",
                        "player_turnovers": "3"
                    },
                    ........
                ],
                ........
            },
      ]
      .......
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;
$from = '2022-04-21';
$to = '2022-04-21';

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Fixtures&APIkey=$APIkey&from=$from&to=$to",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


H2H (Head to Head)


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=H2H

Returns the last games between submiteted teams and the last games of each team


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
timezone The timezone where you want to receive the data in tz format (exemple: America/New_York). Default timezone: Europe/Berlin (Optional)
firstTeamId First team Id
secondTeamId Second team Id

Request URL


JSON Response

{
    "success": 1,
    "result": {
        "H2H": [
            {
                "event_key": "41223",
                "event_date": "2022-04-21",
                "event_time": "01:00",
                "event_home_team": "Boston Celtics",
                "home_team_key": "7",
                "event_away_team": "Brooklyn Nets",
                "away_team_key": "2",
                "event_final_result": "114 - 107",
                "event_status": "Finished",
                "country_name": "USA",
                "league_name": "NBA",
                "league_key": "766",
                "league_round": null,
                "league_season": "2021/2022",
                "event_live": "0"
            },
            ........
          ],
          "firstTeamResults": [
              {
                  "event_key": "41223",
                  "event_date": "2022-04-21",
                  "event_time": "01:00",
                  "event_home_team": "Boston Celtics",
                  "home_team_key": "7",
                  "event_away_team": "Brooklyn Nets",
                  "away_team_key": "2",
                  "event_final_result": "114 - 107",
                  "event_status": "Finished",
                  "country_name": "USA",
                  "league_name": "NBA",
                  "league_key": "766",
                  "league_round": null,
                  "league_season": "2021/2022",
                  "event_live": "0"
              },
              .....
            ],
            "secondTeamResults": [
              {
                  "event_key": "41223",
                  "event_date": "2022-04-21",
                  "event_time": "01:00",
                  "event_home_team": "Boston Celtics",
                  "home_team_key": "7",
                  "event_away_team": "Brooklyn Nets",
                  "away_team_key": "2",
                  "event_final_result": "114 - 107",
                  "event_status": "Finished",
                  "country_name": "USA",
                  "league_name": "NBA",
                  "league_key": "766",
                  "league_round": null,
                  "league_season": "2021/2022",
                  "event_live": "0"
              },
              ......
            ]
        }
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;
$firstTeamId=2;
$secondTeamId=7;

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=H2H&APIkey=$APIkey&firstTeamId=$firstTeamId&secondTeamId=$secondTeamId",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


Livescore


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Livescore

Returns playing now events included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
timezone The timezone where you want to receive the data in tz format (exemple: America/New_York). Default timezone: Europe/Berlin (Optional)
countryId Country ID - if set only events from specific country will be returned (Optional)
leagueId League ID - if set events from specific league will be returned (Optional)
matchId Match ID - if set only details from specific match will be returned (Optional)

Request URL


JSON Response

{
    "success": 1,
    "result": [
        {
            "event_key": "41223",
            "event_date": "2022-04-21",
            "event_time": "01:00",
            "event_home_team": "Boston Celtics",
            "home_team_key": "7",
            "event_away_team": "Brooklyn Nets",
            "away_team_key": "2",
            "event_final_result": "114 - 107",
            "event_quarter": "",
            "event_status": "Finished",
            "country_name": "USA",
            "league_name": "NBA",
            "league_key": "766",
            "league_round": null,
            "league_season": "2021/2022",
            "event_live": "0",
            "event_home_team_logo": "https://apiv2.allsportsapi.com/logo-basketball/7_boston_celtics.jpg",
            "event_away_team_logo": null,
            "scores": {
                "1stQuarter": [
                    {
                        "score_home": "24",
                        "score_away": "33"
                    }
                ],
                "2ndQuarter": [
                    {
                        "score_home": "31",
                        "score_away": "32"
                    }
                ],
                "3rdQuarter": [
                    {
                        "score_home": "30",
                        "score_away": "25"
                    }
                ],
                "4thQuarter": [
                    {
                        "score_home": "29",
                        "score_away": "17"
                    }
                ]
            },
            "statistics": [
                {
                    "type": "Total Assists",
                    "home": "27",
                    "away": "16"
                },
                {
                    "type": "Total Blocks",
                    "home": "4",
                    "away": "8"
                },
                ........
            ],
            "lineups": {
                "home_team": {
                    "starting_lineups": [
                        {
                            "player": "J. Tatum",
                            "player_id": "2673921644"
                        },
                        {
                            "player": "A. Horford",
                            "player_id": "2646138633"
                        },
                        .......
                    ],
                    "substitutes": [
                       {
                           "player": "G. Williams",
                           "player_id": "4155194651"
                       },
                       {
                           "player": "D. White",
                           "player_id": "1528742162"
                       },
                       ......
                     ],
                 },
                 ......
             },
             "player_statistics": {
                "home_team": [
                    {
                        "player": "J. Tatum",
                        "player_id": "2673921644",
                        "player_assists": "10",
                        "player_blocks": "1",
                        "player_defense_rebounds": "5",
                        "player_field_goals_attempts": "16",
                        "player_field_goals_made": "5",
                        "player_freethrows_goals_attempts": "8",
                        "player_freethrows_goals_made": "7",
                        "player_minutes": "41",
                        "player_offence_rebounds": "1",
                        "player_oncourt": "False",
                        "player_personal_fouls": "4",
                        "player_plus_minus": "+11",
                        "player_position": "SF",
                        "player_points": "19",
                        "player_steals": "0",
                        "player_threepoint_goals_attempts": "5",
                        "player_threepoint_goals_made": "2",
                        "player_total_rebounds": "6",
                        "player_turnovers": "3"
                    },
                    ........
                ],
                ........
            },
      ]
      .......
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Livescore&APIkey=$APIkey",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


Standings


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Standings

Returns standings for leagues included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
leagueId League internal code

Request URL


JSON Response

{
    "success": 1,
    "result": {
        "total": [
            {
                "standing_place": "1",
                "standing_place_type": "Promotion - NBA (Play Offs: 1/8-finals)",
                "standing_team": "Phoenix Suns",
                "standing_P": "82",
                "standing_W": "64",
                "standing_WO": "-1",
                "standing_L": "18",
                "standing_LO": "-1",
                "standing_F": "9416",
                "standing_A": "8801",
                "standing_PCT": "",
                "team_key": "16",
                "league_key": "766",
                "league_season": "2021/2022",
                "league_round": "Western Conference",
                "standing_updated": "2022-04-21 10:45:50"
            },
            {
               "standing_place": "2",
               "standing_place_type": "Promotion - NBA (Play Offs: 1/8-finals)",
               "standing_team": "Memphis Grizzlies",
               "standing_P": "82",
               "standing_W": "56",
               "standing_WO": "-1",
               "standing_L": "26",
               "standing_LO": "-1",
               "standing_F": "9480",
               "standing_A": "9014",
               "standing_PCT": "",
               "team_key": "23",
               "league_key": "766",
               "league_season": "2021/2022",
               "league_round": "Western Conference",
               "standing_updated": "2022-04-21 10:45:50"
           },
           .......
     ]
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;
$leagueId = 766;

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Leagues&APIkey=$APIkey&leagueId=$leagueId",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


Teams


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Teams

Returns teams for leagues included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
leagueId League internal code

Request URL


JSON Response

{
    "success": 1,
    "result": [
        {
            "team_key": "1",
            "team_name": "Los Angeles Lakers",
            "team_logo": "https://apiv2.allsportsapi.com/logo-basketball/1_los_angeles_lakers.jpg"
        },
        {
            "team_key": "2",
            "team_name": "Brooklyn Nets",
            "team_logo": null
        },
        {
            "team_key": "3",
            "team_name": "Toronto Raptors",
            "team_logo": "https://apiv2.allsportsapi.com/logo-basketball/3_toronto_raptors.jpg"
        },
        {
            "team_key": "4",
            "team_name": "Philadelphia 76ers",
            "team_logo": "https://apiv2.allsportsapi.com/logo-basketball/4_philadelphia_76ers.jpg"
        },
        .........
    ]
}
            

PHP call example


$APIkey=!_your_account_APIkey_!;
$leagueId = 766;

$curl_options = array(
  CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Teams&APIkey=$APIkey&leagueId=$leagueId",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$result = (array) json_decode($result);

var_dump($result);

            


Odds


Method

GET/POST https://apiv2.allsportsapi.com/basketball/?met=Odds

Returns odds for events included in your current subscription plan


Parameters

Parameter Description
action API method name
APIkey Authorization code generated from your allsportsapi account
from Start date (yyyy-mm-dd)
to Stop date (yyyy-mm-dd)
countryId Country ID - if set only events from specific country will be returned (Optional)
leagueId League ID - if set events from specific league will be returned (Optional)
matchId Match ID - if set only details from specific match will be returned (Optional)

Request URL


JSON Response

{
    "success": 1,
    "result": {
        "41223": {
            "3Way Result": {
                "Home": {
                    "bwin": "1.67",
                    "NordicBet": "1.69",
                    "Marathon": "1.67",
                    "Unibet": "1.72",
                    "Betsson": "1.69",
                    "1xbet": "1.73",
                    "Sportingbet": "1.67",
                    "Betcris": "1.68",
                    "888Sport": "1.72"
                },
                "Draw": {
                    "bwin": "10.00",
                    "NordicBet": "13.00",
                    "Marathon": "18.00",
                    "Unibet": "14.00",
                    "Betsson": "13.00",
                    "1xbet": "13.00",
                    "Sportingbet": "10.00",
                    "Betcris": "14.25",
                    "888Sport": "14.00"
                },
                "Away": {
                    "bwin": "2.45",
                    "NordicBet": "2.40",
                    "Marathon": "2.56",
                    "Unibet": "2.55",
                    "Betsson": "2.40",
                    "1xbet": "2.64",
                    "Sportingbet": "2.45",
                    "Betcris": "2.41",
                    "888Sport": "2.55"
                }
            },
            "Home/Away": {
                "Home": {
                    "bwin": "1.62",
                    "NordicBet": "1.62",
                    "10Bet": "1.62",
                    "WilliamHill": "1.61",
                    "bet365": "1.62",
                    "Marathon": "1.63",
                    "Unibet": "1.62",
                    "Betsson": "1.62",
                    "Pncl": "1.65",
                    "Sbo": "1.64",
                    "Netbet": "1.64",
                    "1xbet": "1.65",
                    "Sportingbet": "1.62",
                    "ComeOn": "1.62",
                    "Betway": "1.65",
                    "Tipico": "1.62",
                    "Betcris": "1.62",
                    "888Sport": "1.62"
                },
                .......
            },
            .....
        },
        ......
    }
}
              

PHP call example


  $APIkey=!_your_account_APIkey_!;
  $eventId = 41223;

  $curl_options = array(
    CURLOPT_URL => "https://apiv2.allsportsapi.com/basketball/?met=Odds&APIkey=$APIkey&matchId=$eventId",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER => false,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_CONNECTTIMEOUT => 5
  );

  $curl = curl_init();
  curl_setopt_array( $curl, $curl_options );
  $result = curl_exec( $curl );

  $result = (array) json_decode($result);

  var_dump($result);