NAV Navbar
Php Python Javascript Swift cURL Ruby

Introduction

Welcome to Api-Basketball! You can use our API to access all API endpoints, which can get information about 115 Basketball Leagues & Cups.

We have language bindings in Php, Shell, Ruby, Python, Swift and JavaScript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Authentication

To authorize, use this code:

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/{endpoint}');
$request->setRequestMethod('GET');
$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/{endpoint}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/{endpoint}", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/{endpoint}")! as URL,
    cachePolicy: .useProtocolCachePolicy,
    timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
curl --request GET \
    --url https://api-basketball.p.rapidapi.com/{endpoint} \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/{endpoint}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

Make sure to replace XxXxXxXxXxXxXxXxXxXxXxXx with your API key.

We uses API keys to allow access to the API. You can register a new API key in rapidapi.

Our API expects for the API key to be included in all API requests to the server in a header that looks like the following:

x-rapidapi-host: api-basketball.p.rapidapi.com

x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx

Account

All information related to your subscription are available on the rapidApi developer dashboard.

The RapidAPI developer dashboard is where you can see all of your apps, locate API keys, view analytics, and manage billing settings.

To access the dashboard, simply login to RapidAPI and select 'My Apps' in the top-right menu. Alternatively, you can head directly to https://rapidapi.com/developer/dashboard.

In the main dashboard, you will see account-wide analytics and account information. To get more detailed information, you can select tabs on the left-hand side of the screen.

App Specific Analytics

Using the RapidAPI dashboard, you can also view analytics specific to each app in your account. To do so, switch over to the 'Analytics' tab of your application in the dashboard.

On the top of the page, you'll be able to see a chart with all the calls being made to all the APIs your app is connected to. You'll also be able to see a log with all the request data. You are also able to filter these analytics to only show certain APIs within the app.

In each graph, you can view the following metrics:

You may change the time period you're looking at by clicking the calendar icon and choosing a time range.

Headers sent as response

When consuming our API, you will always receive the following headers appended to the response:

Architecture

Timezone

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/timezone');
$request->setRequestMethod('GET');
$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/timezone", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/timezone", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/timezone")! as URL,
    cachePolicy: .useProtocolCachePolicy,
    timeoutInterval: 10.0)

request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
curl --request GET \
    --url https://api-basketball.p.rapidapi.com/timezone \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/timezone")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "timezone",
    "parameters": [],
    "errors": [],
    "results": 425,
    "response": [
        "Africa/Abidjan",
        "Africa/Accra",
        "Africa/Addis_Ababa",
        "Africa/Algiers",
        "Africa/Asmara",
    ]
}

Description

This endpoint retrieves all available time zones.

All returned time zones can be used in the games endpoint, in order to have the dates and times in the time zone of your choice.

Endpoint

GET https://api-basketball.p.rapidapi.com/timezone

Seasons

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/seasons');
$request->setRequestMethod('GET');
$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/seasons", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/seasons", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/seasons")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url https://api-basketball.p.rapidapi.com/seasons \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/seasons")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "seasons",
    "parameters": [],
    "errors": [],
    "results": 8,
    "response": [
        "2015-2016",
        "2016-2017",
        2017,
        "2017-2018",
        2018,
        "2018-2019",
        2019,
        "2019-2020"
    ]
}

Description

This endpoint retrieves all available seasons.

All {season} can be used in other endpoints as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/seasons

Countries

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/countries');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'search' => 'usa'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/countries?search=usa", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/countries?search=usa", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/countries?search=usa")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/countries?search=usa' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/countries?search=usa")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "countries",
    "parameters": {
        "search": "usa"
    },
    "errors": [],
    "results": 1,
    "response": [
        {
            "id": 5,
            "name": "USA",
            "code": "US",
            "flag": "https://media.api-football.com/flags/us.svg"
        }
    ]
}

Description

This endpoint retrieves all available countries.

All countries {id}, {name} and {code} can be used in other endpoints as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/countries

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the country 5
name string False The NAME of the country USA
code string False The CODE of the country US
search string False The NAME of the country, 3 characters minimum usa

Sample request

All

GET https://api-basketball.p.rapidapi.com/countries

By country id

GET https://api-basketball.p.rapidapi.com/countries?id=5

By country name

GET https://api-basketball.p.rapidapi.com/countries?name=usa

By country code

GET https://api-basketball.p.rapidapi.com/countries?code=us

Search by country name

GET https://api-basketball.p.rapidapi.com/countries?search=usa

Leagues

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/countries');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'search' => 'usa',
    'id' => '12'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/countries?search=usa&id=12", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/countries?search=usa&id=12", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/countries?search=usa&id=12")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/countries?search=usa&id=12' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/countries?search=usa&id=12")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "leagues",
    "parameters": {
        "id": "12"
    },
    "errors": [],
    "results": 1,
    "response": [
        {
            "id": 12,
            "name": "NBA",
            "type": "League",
            "logo": null,
            "country": {
                "id": 5,
                "name": "USA",
                "code": "US",
                "flag": "https://media.api-football.com/flags/us.svg"
            },
            "seasons": [
                {
                    "season": "2019-2020",
                    "start": "2019-10-04",
                    "end": "2020-04-16"
                },
                {
                    "season": "2018-2019",
                    "start": "2018-09-28",
                    "end": "2019-05-24"
                },
                {
                    "season": "2017-2018",
                    "start": "2017-10-01",
                    "end": "2018-06-09"
                },
                {
                    "season": "2016-2017",
                    "start": "2016-10-01",
                    "end": "2017-06-13"
                },
                {
                    "season": "2015-2016",
                    "start": "2015-10-03",
                    "end": "2016-06-20"
                }
            ]
        }
    ]
}

Description

This endpoint retrieves all available leagues.

All league {id} can be used in other endpoints as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/leagues

Update Frequency

The data in this endpoint is updated daily.

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the league 12
name string False The NAME of the league NBA
country_id integer False The ID of the country 5
country string False The NAME of the country USA
code string False The CODE of the country FR, GB, IT…
season string False The SEASON of the league 2019 or 2019-2020
type string False The TYPE of the league league or cup
search string False The NAME of the country, 3 characters minimum nba

Sample request

All

GET https://api-basketball.p.rapidapi.com/leagues

By league id

GET https://api-basketball.p.rapidapi.com/leagues?id=12

By league name

GET https://api-basketball.p.rapidapi.com/leagues?name=nba

By courtry id

GET https://api-basketball.p.rapidapi.com/leagues?country_id=8

By country name

GET https://api-basketball.p.rapidapi.com/leagues?country=chile

By country code

GET https://api-basketball.p.rapidapi.com/leagues?code=gb

By season

GET https://api-basketball.p.rapidapi.com/leagues?season=2019-2020

Search by league name

GET https://api-basketball.p.rapidapi.com/leagues?search=lnb

By type

GET https://api-basketball.p.rapidapi.com/leagues?type=league

By mixing country name, season and type

GET https://api-basketball.p.rapidapi.com/leagues?country=chile&season=2019-2020&type=league

By mixing league name and season

GET https://api-basketball.p.rapidapi.com/leagues?name=lnb&season=2019-2020

Teams

Data

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/teams');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'name' => 'Denver Nuggets'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/teams?name=Denver%20Nuggets", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/teams?name=Denver%20Nuggets", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/teams?name=Denver%20Nuggets")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/teams?name=Denver%20Nuggets' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/teams?name=Denver%20Nuggets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "teams",
    "parameters": {
        "name": "Denver Nuggets"
    },
    "errors": [],
    "results": 1,
    "response": [
        {
            "id": 139,
            "name": "Denver Nuggets",
            "nationnal": false,
            "logo": null,
            "country": {
                "id": 5,
                "name": "USA",
                "code": "US",
                "flag": "https://media.api-football.com/flags/us.svg"
            }
        }
    ]
}

Description

This endpoint retrieves all available teams.

All teams {id} can be used in other endpoints as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/teams

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the team 139
name string False The NAME of the team Denver Nuggets
league integer False The LEAGUE of the team 12
season string False The SEASON of the league 2019 or 2019-2020
search string False The NAME of the team, 3 characters minimum denver

Sample request

By team id

GET https://api-basketball.p.rapidapi.com/teams?id=32

By team name

GET https://api-basketball.p.rapidapi.com/teams?name=Denver Nuggets

By league id and season (league and season must be used together)

GET https://api-basketball.p.rapidapi.com/teams?league=12&season=2019-2020

Search by team name

GET https://api-basketball.p.rapidapi.com/teams?search=denver

Statistics

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/statistics');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'league' => '12',
    'season' => '2019-2020',
    'team' => '139'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/statistics?league=12&season=2019-2020&team=139", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "statistics",
    "parameters": {
        "league": "12",
        "season": "2019-2020",
        "team": "139"
    },
    "errors": [],
    "results": 5,
    "response": {
        "league": {
            "id": 12,
            "name": "NBA",
            "type": "League",
            "season": "2019-2020",
            "logo": null
        },
        "country": {
            "id": 5,
            "name": "USA",
            "code": "US",
            "flag": "https://media.api-football.com/flags/us.svg"
        },
        "team": {
            "id": 139,
            "name": "Denver Nuggets",
            "logo": null
        },
        "games": {
            "played": {
                "home": 9,
                "away": 9,
                "all": 18
            },
            "wins": {
                "home": {
                    "total": 7,
                    "percentage": "0.778"
                },
                "away": {
                    "total": 8,
                    "percentage": "0.889"
                },
                "all": {
                    "total": 15,
                    "percentage": "0.833"
                }
            },
            "draws": {
                "home": {
                    "total": 0,
                    "percentage": "0.000"
                },
                "away": {
                    "total": 0,
                    "percentage": "0.000"
                },
                "all": {
                    "total": 0,
                    "percentage": "0.000"
                }
            },
            "loses": {
                "home": {
                    "total": 2,
                    "percentage": "0.222"
                },
                "away": {
                    "total": 1,
                    "percentage": "0.111"
                },
                "all": {
                    "total": 3,
                    "percentage": "0.167"
                }
            }
        },
        "points": {
            "for": {
                "total": {
                    "home": 956,
                    "away": 961,
                    "all": 1917
                },
                "average": {
                    "home": "106.2",
                    "away": "106.8",
                    "all": "106.5"
                }
            },
            "against": {
                "total": {
                    "home": 911,
                    "away": 902,
                    "all": 1813
                },
                "average": {
                    "home": "101.2",
                    "away": "100.2",
                    "all": "100.7"
                }
            }
        }
    }
}

Description

This endpoint retrieves all available teams statistics.

Endpoint

GET https://api-basketball.p.rapidapi.com/statistics

Update Frequency

The data in this endpoint is updated in real time.

Query Parameters

Parameter Type Required Description Example
team integer True The ID of the team 139
league integer True The ID of the league 12
season string True The SEASON of the league 2019 or 2019-2020
date string False The limit DATE 2020-01-31

Sample request

By team id, league id and season (Theses parameters are required)

GET https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139"

By team id, league id, season and date

GET https://api-basketball.p.rapidapi.com/statistics?league=12&season=2019-2020&team=139&date=2019-10-22

Standings

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/standings');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'league' => '12',
    'season' => '2019-2020'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/standings?league=12&season=2019-2020", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "standings",
    "parameters": {
        "league": "12",
        "season": "2019-2020",
        "team": "137"
    },
    "errors": [],
    "results": 1,
    "response": [
        [
            {
                "position": 14,
                "stage": "NBA - Regular Season",
                "group": {
                    "name": "Eastern Conference",
                    "points": null
                },
                "team": {
                    "id": 137,
                    "name": "Cleveland Cavaliers",
                    "logo": null
                },
                "league": {
                    "id": 12,
                    "name": "NBA",
                    "type": "League",
                    "season": "2019-2020",
                    "logo": null
                },
                "country": {
                    "id": 5,
                    "name": "USA",
                    "code": "US",
                    "flag": "https://media.api-football.com/flags/us.svg"
                },
                "games": {
                    "played": 15,
                    "win": {
                        "total": 4,
                        "percentage": "0.267"
                    },
                    "lose": {
                        "total": 11,
                        "percentage": "0.733"
                    }
                },
                "points": {
                    "for": 1559,
                    "against": 1682
                },
                "form": "LLLLL",
                "description": null
            }
        ]
    ]
}

Description

This endpoint retrieves all available standings for a league or cup.

Return a table of one or more rankings according to the league / cup. Some competitions have several rankings in a year, group phase, opening ranking, closing ranking etc…

Endpoint

GET https://api-basketball.p.rapidapi.com/standings

Update Frequency

The data in this endpoint is updated every hours.

Query Parameters

Parameter Type Required Description Example
league integer True The ID of the league 12
season string True The SEASON of the league 2019 or 2019-2020
team integer False The ID of the team 137

Sample request

By league id and season

GET https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020

By league id, season and team id

GET https://api-basketball.p.rapidapi.com/standings?league=12&season=2019-2020&team=137

Games

Data

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/games');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'season' => '2019-2010',
    'timezone' => 'europe%2Flondon',
    'league' => '12',
    'date' => '2019-11-23',
    'team' => '134'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/games?season=2019-2010&timezone=europe%252Flondon&league=12&date=2019-11-23&team=134", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/games?season=2019-2010&timezone=europe%252Flondon&league=12&date=2019-11-23&team=134", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/games?season=2019-2010&timezone=europe%252Flondon&league=12&date=2019-11-23&team=134")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/games?season=2019-2010&timezone=europe%252Flondon&league=12&date=2019-11-23&team=134' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/games?season=2019-2010&timezone=europe%252Flondon&league=12&date=2019-11-23&team=134")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "games",
    "parameters": {
        "league": "12",
        "date": "2019-11-23",
        "team": "134",
        "timezone": "europe/london",
        "season": "2019-2020"
    },
    "errors": [],
    "results": 1,
    "response": [
        {
            "id": 1911,
            "date": "2019-11-23T00:30:00+00:00",
            "time": "00:30",
            "timestamp": 1574469000,
            "timezone": "europe/london",
            "stage": null,
            "week": null,
            "status": {
                "long": "Game Finished",
                "short": "FT",
                "timer": null
            },
            "league": {
                "id": 12,
                "name": "NBA",
                "type": "League",
                "season": "2019-2020",
                "logo": null
            },
            "country": {
                "id": 5,
                "name": "USA",
                "code": "US",
                "flag": "https://media.api-football.com/flags/us.svg"
            },
            "teams": {
                "home": {
                    "id": 134,
                    "name": "Brooklyn Nets",
                    "logo": null
                },
                "away": {
                    "id": 157,
                    "name": "Sacramento Kings",
                    "logo": null
                }
            },
            "scores": {
                "home": {
                    "quarter_1": 26,
                    "quarter_2": 30,
                    "quarter_3": 30,
                    "quarter_4": 30,
                    "over_time": null,
                    "total": 116
                },
                "away": {
                    "quarter_1": 23,
                    "quarter_2": 26,
                    "quarter_3": 21,
                    "quarter_4": 27,
                    "over_time": null,
                    "total": 97
                }
            }
        }
    ]
}

Description

This endpoint retrieves all available games informations.

For all requests to games you can add the query parameter {timezone} to your request in order to retrieve the list of matches in the time zone of your choice like Europe/London

To know the list of available time zones you have to use the endpoint timezone

Available games status

Endpoint

GET https://api-basketball.p.rapidapi.com/games

Update Frequency

The data in this endpoint is updated every 15 seconds.

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the game 1911
league integer False The ID of the league 12
season string False The SEASON of the league 2019 or 2019-2020
team integer False The ID of the team 134
date string False The DATE of our choice 2019-11-23
timezone string False The TIMEZONE of your choice europe/london

Sample request

By game id

GET https://api-basketball.p.rapidapi.com/games?id=1154

By league id and season

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020

By team id

GET https://api-basketball.p.rapidapi.com/games?team=134

By date

GET https://api-basketball.p.rapidapi.com/games?date=2019-11-23

By mixing team id and date

GET https://api-basketball.p.rapidapi.com/games?team=134&date=2019-11-23

By mixing league id and season

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020

By mixing league id, season and date

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&date=2019-11-23

By mixing league id, season, team id, date and timezone

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&team=134&date=2019-11-23&timezone=europe/london

H2h

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/games');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'league' => '12',
    'season' => '2019-2020',
    'h2h' => '132-134'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/games?league=12&season=2019-2020&h2h=132-134", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "games",
    "parameters": {
        "league": "12",
        "h2h": "132-134",
        "season": "2019-2020"
    },
    "errors": [],
    "results": 4,
    "response": [
        {
            "id": 2003,
            "date": "2019-12-05T00:30:00+00:00",
            "time": "00:30",
            "timestamp": 1575505800,
            "timezone": "UTC",
            "stage": null,
            "week": null,
            "status": {
                "long": "Not Started",
                "short": "NS",
                "timer": null
            },
            "league": {
                "id": 12,
                "name": "NBA",
                "type": "League",
                "season": "2019-2020",
                "logo": null
            },
            "country": {
                "id": 5,
                "name": "USA",
                "code": "US",
                "flag": "https://media.api-football.com/flags/us.svg"
            },
            "teams": {
                "home": {
                    "id": 132,
                    "name": "Atlanta Hawks",
                    "logo": null
                },
                "away": {
                    "id": 134,
                    "name": "Brooklyn Nets",
                    "logo": null
                }
            },
            "scores": {
                "home": {
                    "quarter_1": null,
                    "quarter_2": null,
                    "quarter_3": null,
                    "quarter_4": null,
                    "over_time": null,
                    "total": null
                },
                "away": {
                    "quarter_1": null,
                    "quarter_2": null,
                    "quarter_3": null,
                    "quarter_4": null,
                    "over_time": null,
                    "total": null
                }
            }
        }
    ]
}

This endpoint retrieves all available games between two teams.

Endpoint

GET https://api-basketball.p.rapidapi.com/games

Update Frequency

The data in this endpoint is updated every 15 seconds.

Query Parameters

Parameter Type Required Description Example
h2h string True The teams IDs 132-134
league integer False The ID of the league 12
season string False The SEASON of the league 2019 or 2019-2020
timezone string False The TIMEZONE of your choice europe/london

Sample request

All

GET https://api-basketball.p.rapidapi.com/games?h2h=132-134

By teams ids, league and season

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134

By teams ids, league, season and timezone

GET https://api-basketball.p.rapidapi.com/games?league=12&season=2019-2020&h2h=132-134&timezone=Europe/London

Odds

Bookmakers

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/bookmakers');
$request->setRequestMethod('GET');
$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/bookmakers", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/bookmakers", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/bookmakers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url https://api-basketball.p.rapidapi.com/bookmakers \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/bookmakers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "bookmakers",
    "parameters": [],
    "errors": [],
    "results": 15,
    "response": [
        {
            "id": 1,
            "name": "Bwin"
        },
        {
            "id": 2,
            "name": "Marathon Bet"
        },
        {
            "id": 3,
            "name": "1xBet"
        },
        {
            "id": 4,
            "name": "Bet365"
        },
        {
            "id": 5,
            "name": "Bovada"
        },
        {
            "id": 6,
            "name": "Betcris"
        },
        {
            "id": 7,
            "name": "10Bet"
        },
        {
            "id": 8,
            "name": "5Dimes"
        },
        {
            "id": 9,
            "name": "Betfair"
        },
        {
            "id": 10,
            "name": "188bet"
        },
        {
            "id": 11,
            "name": "Intertops"
        },
        {
            "id": 12,
            "name": "Pinnacle"
        },
        {
            "id": 13,
            "name": "Sport Betting Online"
        },
        {
            "id": 14,
            "name": "BetFred"
        },
        {
            "id": 15,
            "name": "BetUS"
        }
    ]
}

Description

This endpoint retrieves all available bookmakers.

All bookmakers {id} can be used in endpoint odds as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/bookmakers

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the bookmaker 1
search string False The NAME of the bookmaker, 3 characters minimum bwin

Sample request

All

GET https://api-basketball.p.rapidapi.com/bookmakers

By bookmaker id

GET https://api-basketball.p.rapidapi.com/bookmakers?id=8

Search by bookmaker name

GET https://api-basketball.p.rapidapi.com/bookmakers?search=bet365

Bets

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/bets');
$request->setRequestMethod('GET');
$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/bets", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/bets", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/bets")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url https://api-basketball.p.rapidapi.com/bets \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/bets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "bets",
    "parameters": {
        "search": "under"
    },
    "errors": [],
    "results": 7,
    "response": [
        {
            "id": 1,
            "name": "3Way Result"
        },
        {
            "id": 2,
            "name": "Home/Away"
        },
        {
            "id": 3,
            "name": "Asian Handicap"
        },
        {
            "id": 4,
            "name": "Over/Under"
        },
        {
            "id": 5,
            "name": "Over/Under 1st Half"
        },
        {
            "id": 6,
            "name": "Highest Scoring Half"
        },
        {
            "id": 7,
            "name": "Double Chance"
        },
        {
            "id": 8,
            "name": "1st Half 3Way Result"
        },
        {
            "id": 9,
            "name": "Handicap Result 1st Half"
        },
        {
            "id": 10,
            "name": "Asian Handicap First Half"
        },
        {
            "id": 11,
            "name": "Asian Handicap 2nd Qtr"
        },
        {
            "id": 12,
            "name": "Odd/Even (Including OT)"
        },
        {
            "id": 13,
            "name": "Odd/Even 1st Half"
        },
        {
            "id": 14,
            "name": "3Way Result - 1st Qtr"
        },
        {
            "id": 15,
            "name": "HT/FT (Including OT)"
        },
        {
            "id": 16,
            "name": "Over/Under 1st Qtr"
        },
        {
            "id": 17,
            "name": "Asian Handicap 1st Qtr"
        },
        {
            "id": 18,
            "name": "Home/Away - 1st Half"
        },
        {
            "id": 19,
            "name": "Home/Away - 1st Qtr"
        }
    ]
}

Description

This endpoint retrieves all available bets for odds.

All bets {id} can be used in endpoint odds as filters.

Endpoint

GET https://api-basketball.p.rapidapi.com/bets

Query Parameters

Parameter Type Required Description Example
id integer False The ID of the bet 1
search string False The NAME of the bet, 3 characters minimum under

Sample request

All

GET https://api-basketball.p.rapidapi.com/bets

By bet id

GET https://api-basketball.p.rapidapi.com/bets?id=47

Search by bet name

GET https://api-basketball.p.rapidapi.com/bets?search=under

Odds

<?php
$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api-basketball.p.rapidapi.com/odds');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
    'bet' => '2',
    'game' => '1912'
)));

$request->setHeaders(array(
    'x-rapidapi-host' => 'api-basketball.p.rapidapi.com',
    'x-rapidapi-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
?>
import http.client

conn = http.client.HTTPSConnection("api-basketball.p.rapidapi.com")

headers = {
    'x-rapidapi-host': "api-basketball.p.rapidapi.com",
    'x-rapidapi-key': "XxXxXxXxXxXxXxXxXxXxXxXx"
    }

conn.request("GET", "/odds?bet=2&game=1912", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
fetch("https://api-basketball.p.rapidapi.com/odds?bet=2&game=1912", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "api-basketball.p.rapidapi.com",
        "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.log(err);
});
import Foundation

let headers = [
    "x-rapidapi-host": "api-basketball.p.rapidapi.com",
    "x-rapidapi-key": "XxXxXxXxXxXxXxXxXxXxXxXx"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-basketball.p.rapidapi.com/odds?bet=2&game=1912")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
        print(error)
    } else {
        let httpResponse = response as? HTTPURLResponse
        print(httpResponse)
    }
})

dataTask.resume()
curl --request GET \
    --url 'https://api-basketball.p.rapidapi.com/odds?bet=2&game=1912' \
    --header 'x-rapidapi-host: api-basketball.p.rapidapi.com' \
    --header 'x-rapidapi-key: XxXxXxXxXxXxXxXxXxXxXxXx'
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api-basketball.p.rapidapi.com/odds?bet=2&game=1912")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["x-rapidapi-host"] = 'api-basketball.p.rapidapi.com'
request["x-rapidapi-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx'

response = http.request(request)
puts response.read_body

The above request returns JSON structured like this:

{
    "get": "odds",
    "parameters": {
        "bet": "2",
        "game": "1912"
    },
    "errors": [],
    "results": 1,
    "response": [
        {
            "league": {
                "id": 12,
                "name": "NBA",
                "type": "League",
                "season": "2019-2020",
                "logo": null
            },
            "country": {
                "id": 5,
                "name": "USA",
                "code": "US",
                "flag": "https://media.api-football.com/flags/us.svg"
            },
            "game": {
                "id": 1912
            },
            "bookmakers": [
                {
                    "id": 1,
                    "name": "bwin",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.30"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.60"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 7,
                    "name": "10Bet",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.33"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.45"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 4,
                    "name": "bet365",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.34"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.35"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 2,
                    "name": "Marathon",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.36"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.44"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 8,
                    "name": "5Dimes",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.36"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.55"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 9,
                    "name": "Betfair",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.33"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.25"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 10,
                    "name": "188bet",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.32"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.60"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 11,
                    "name": "Intertops",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.33"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.50"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 12,
                    "name": "Pncl",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.34"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.51"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 13,
                    "name": "Sbo",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.32"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.38"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 3,
                    "name": "1xBet",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.37"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.42"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 14,
                    "name": "BetFred",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.33"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.25"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 5,
                    "name": "Bovada",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.33"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.50"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 15,
                    "name": "BetUS",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.36"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.35"
                                }
                            ]
                        }
                    ]
                },
                {
                    "id": 6,
                    "name": "Betcris",
                    "bets": [
                        {
                            "id": 2,
                            "name": "Home/Away",
                            "values": [
                                {
                                    "value": "Home",
                                    "odd": "1.32"
                                },
                                {
                                    "value": "Away",
                                    "odd": "3.39"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

Description

This endpoint retrieves all available odds.

We provide pre-match odds between 1 and 7 days before the game.

Endpoint

GET https://api-basketball.p.rapidapi.com/odds

Update Frequency

The data in this endpoint is updated once a day.

Query parameters

Parameter Type Required Description Example
game integer False The ID of the game 1
league integer False The ID of the league 12
season string False The SEASON of the league 2019 or 2019-2020
bookmaker integer False The ID of the bookmaker 1
bet integer False The ID of the bet 2

Sample request

By game id

GET https://api-basketball.p.rapidapi.com/odds?game=1912

By league id and season

GET https://api-basketball.p.rapidapi.com/odds?league=12&season=2019-2020

By mixing game id, bookmaker id and bet id

GET https://api-basketball.p.rapidapi.com/odds?game=1912&bookmaker=4&bet=5

By mixing game id and bet id

GET https://api-basketball.p.rapidapi.com/odds?game=1912&bet=5

By mixing league id, game id, bookmaker id and season

GET https://api-basketball.p.rapidapi.com/odds?league=12&game=1912&bookmaker=4&season=2019-2020

Errors

Missing / wrong API KEY:

{
    "message": "Missing RapidAPI application key. Go to https://docs.rapidapi.com/docs/keys to learn how to get your API application key."
}

Missing / wrong endpoint:

{
    "get": "ggames?id=12",
    "parameters": {
        "id": "12"
    },
    "errors": {
        "endpoint": "This endpoint do not exist."
    },
    "results": 0,
    "response": []
}

Missing / wrong parameter:

{
    "get": "games?idd=12",
    "parameters": {
        "idd": "12"
    },
    "errors": {
        "idd": "The Idds field do not exist."
    },
    "results": 0,
    "response": []
}

API Bug:

{
    "get": "games?id=12",
    "parameters": {
        "id": "12"
    },
    "errors": {
        "time": "2019-11-26T00:00:00+00:00",
        "bug": "This is on our side, please report us this bug at support@api-football.com",
        "report": "games?id=12",
    },
    "results": 0,
    "response": []
}

Time Out:

{
    "message": "Something went wrong while fetching details. Try again later."
}

Internal Server Error:

{
    "message": "Something went wrong while fetching details. Try again later."
}

You will find in this area a set of error codes that you may receive from the API depending on your requests or the availability of our services.

Code Meaning
200 Api Key -- Missing RapidAPI application key. Go to https://docs.rapidapi.com/docs/keys to learn how to get your API application key.
200 Endpoint -- This endpoint do not exist.
200 Parameters -- At least one parameter is required.
200 Parameters -- The ____ field do not exist.
200 Parameters -- The ____ field cannot be empty.
200 Parameters -- The ____ field must contain a valid date: Y-m-d.
200 Parameters -- The ____ field must be used alone.
200 Parameters -- The ____ field cannot be used alone.
200 Parameters -- The ____ field cannot be used with ____ field.
499 Time Out -- We had a problem with our server. Try again later.
500 Internal Server Error -- We had a problem with our server. Try again later.