Get odds from games or leagues. We provide pre-match odds between 1 and 7 days before the game. We keep a 7-day history *(The availability of odds may vary according to the leagues, seasons, games and bookmakers)* > Odds are updated once a day
API-SPORTS American Football API
# Introduction Welcome to Api-Basketball! You can use our API to access all API endpoints, which can get information about Basketball Leagues & Cups. We have language bindings in C, C#, cURL, Dart, Go, Java, Javascript, NodeJs, Objective-c, OCaml, Php, PowerShell, Python, Ruby, Shell and Swift! 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 We uses API keys to allow access to the API. You can register a new API key directly on our [dashboard](https://dashboard.api-football.com/register). API-SPORTS : https://v1.basketball.api-sports.io/ 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: > Make sure to replace `XxXxXxXxXxXxXxXxXxXxXxXx` with your API key. REQUESTS HEADERS & CORS The API is configured to work only with GET requests and allows only the headers listed below: * `x-apisports-key` If you make non-GET requests or add headers that are not in the list, you will receive an error from the API. Some frameworks *(especially in JS, nodeJS..)* automatically add extra headers, you have to make sure to remove them in order to get a response from the API. ## API-SPORTS Account If you decided to subscribe directly on our site, you have a dashboard at your disposal at the following url: [dashboard](https://dashboard.api-football.com/register) It allows you to: * To follow your consumption in real time * Manage your subscription and change it if necessary * Check the status of our servers * Test all endpoints without writing a line of code. You can also consult all this information directly through the API by calling the endpoint `status`. > This call does not count against the daily quota. ```json get("https://v1.basketball.api-sports.io/status"); // response { "get": "status", "parameters": [], "errors": [], "results": 1, "response": { "account": { "firstname": "xxxx", "lastname": "XXXXXX", "email": "xxx@xxx.com" }, "subscription": { "plan": "Free", "end": "2020-04-10T23:24:27+00:00", "active": true }, "requests": { "current": 12, "limit_day": 100 } } } ``` ### Headers sent as response When consuming our API, you will always receive the following headers appended to the response: * `x-ratelimit-requests-limit`: The number of requests allocated per day according to your subscription. * `x-ratelimit-requests-remaining`: The number of remaining requests per day according to your subscription. * `X-RateLimit-Limit`: Maximum number of API calls per minute. * `X-RateLimit-Remaining`: Number of API calls remaining before reaching the limit per minute. ### Dashboard  ### Requests  ### Live tester  # Architecture  # Logos / Images Calls to logos/images do not count towards your daily quota and are provided for free. However these calls are subject to a rate per second & minute, it is recommended to save this data on your side in order not to slow down or impact the user experience of your application or website. For this you can use CDNs such as [bunny.net](https://bunny.net?ref=8r6al7jhm4). We have a tutorial available [here](https://www.api-football.com/news/post/optimizing-sports-websites-bunnycdn-api-sports-image-storage-guide), which explains how to set up your own media system with BunnyCDN. Logos, images and trademarks delivered through the API are provided solely for identification and descriptive purposes (e.g., identifying leagues, teams, players or venues). We does not own any of these visual assets, and no intellectual property rights are claimed over them. Some images or data may be subject to intellectual property or trademark rights held by third parties (including but not limited to leagues, federations, or clubs). The use of such content in your applications, websites, or products may require additional authorization or licensing from the respective rights holders. You are fully responsible for ensuring that your usage of any logos, images, or branded content complies with applicable laws in your country or the countries where your services are made available. We are not affiliated with, sponsored by, or endorsed by any sports league, federation, or brand featured in the data provided. # Sample Scripts Here are some examples of how the API is used in the main development languages. You have to replace `{endpoint}` by the real name of the endpoint you want to call, like `leagues` or `games` for example. In all the sample scripts we will use the `leagues` endpoint as example. Also you will have to replace `XxXxXxXxXxXxXxXxXxXxXx` with your API-KEY provided in the [dashboard](https://dashboard.api-football.com/). ## C `libcurl` ```shell CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://v1.basketball.api-sports.io/leagues"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); } curl_easy_cleanup(curl); ``` ## C# `RestSharp` ```shell var client = new RestClient("https://v1.basketball.api-sports.io/leagues"); client. Timeout = -1; var request = new RestRequest(Method.GET); request. AddHeader("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); IRestResponse response = client. Execute(request); Console. WriteLine(response. Content); ``` ## cURL `Curl` ```shell curl --request GET \ --url https://v1.basketball.api-sports.io/leagues \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' ``` ## Dart `http` ```dart var headers = { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', }; var request = http. Request('GET', Uri.parse('https://v1.basketball.api-sports.io/leagues')); request.headers.addAll(headers); http. StreamedResponse response = await request.send(); if (response.statusCode == 200) { print(await response.stream.bytesToString()); } else { print(response.reasonPhrase); } ``` ## Go `Native` ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://v1.basketball.api-sports.io/leagues" method := "GET" client := &http. Client { } req, err := http. NewRequest(method, url, nil) if err != nil { fmt. Println(err) return } req. Header. Add("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") res, err := client. Do(req) if err != nil { fmt. Println(err) return } defer res. Body. Close() body, err := ioutil. ReadAll(res. Body) if err != nil { fmt. Println(err) return } fmt. Println(string(body)) } ``` ## Java `OkHttp` ```java var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; ``` `Unirest` ```java Unirest.setTimeouts(0, 0); HttpResponse response = Unirest.get("https://v1.basketball.api-sports.io/leagues") .header("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") .asString(); ``` ## Javascript `Fetch` ```javascript var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://v1.basketball.api-sports.io/leagues", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` `jQuery` ```javascript var settings = { "url": "https://v1.basketball.api-sports.io/leagues", "method": "GET", "timeout": 0, "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx", }, }; $.ajax(settings).done(function (response) { console.log(response); }); ``` `XHR` ```javascript var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function() { if(this.readyState === 4) { console.log(this.responseText); } }); xhr.open("GET", "https://v1.basketball.api-sports.io/leagues"); xhr.setRequestHeader("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); xhr.send(); ``` ## NodeJs `Axios` ```nodejs var axios = require('axios'); var config = { method: 'get', url: 'https://v1.basketball.api-sports.io/leagues', headers: { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', } }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); }); ``` `Native` ```nodejs var https = require('follow-redirects').https; var fs = require('fs'); var options = { 'method': 'GET', 'hostname': 'v1.basketball.api-sports.io', 'path': '/leagues', 'headers': { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', }, 'maxRedirects': 20 }; var req = https.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { var body = Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); req.end(); ``` `Requests` ```nodejs var request = require('request'); var options = { 'method': 'GET', 'url': 'https://v1.basketball.api-sports.io/leagues', 'headers': { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` `Unirest` ```nodejs var unirest = require('unirest'); var req = unirest('GET', 'https://v1.basketball.api-sports.io/leagues') .headers({ 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', }) .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` ## Objective-c `NSURLSession` ```objectivec #import dispatch_semaphore_t sema = dispatch_semaphore_create(0); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://v1.basketball.api-sports.io/leagues"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; NSDictionary *headers = @{ @"x-apisports-key": @"XxXxXxXxXxXxXxXxXxXxXxXx", }; [request setAllHTTPHeaderFields: headers]; [request setHTTPMethod:@"GET"]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); dispatch_semaphore_signal(sema); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSError *parseError = nil; NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData: data options:0 error:&parseError]; NSLog(@"%@",responseDictionary); dispatch_semaphore_signal(sema); } }]; [dataTask resume]; dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); ``` ## OCaml `Cohttp` ```ocaml open Lwt open Cohttp open Cohttp_lwt_unix let reqBody = let uri = Uri.of_string "https://v1.basketball.api-sports.io/leagues" in let headers = Header.init () |> fun h -> Header.add h "x-apisports-key" "XxXxXxXxXxXxXxXxXxXxXxXx" in Client.call ~headers `GET uri >>= fun (_resp, body) -> body |> Cohttp_lwt. Body.to_string >|= fun body -> body let () = let respBody = Lwt_main.run reqBody in print_endline (respBody) ``` ## Php `cURL` ```php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://v1.basketball.api-sports.io/leagues', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx', ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` `Request2` ```php <?php require_once 'HTTP/Request2.php'; $request = new HTTP_Request2(); $request->setUrl('https://v1.basketball.api-sports.io/leagues'); $request->setMethod(HTTP_Request2::METHOD_GET); $request->setConfig(array( 'follow_redirects' => TRUE )); $request->setHeader(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx', )); try { $response = $request->send(); if ($response->getStatus() == 200) { echo $response->getBody(); } else { echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase(); } } catch(HTTP_Request2_Exception $e) { echo 'Error: ' . $e->getMessage(); } ``` `Http` ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.basketball.api-sports.io/leagues'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ## PowerShell `RestMethod` ```powershell $headers = New-Object "System. Collections. Generic. Dictionary[[String],[String]]" $headers. Add("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") $response = Invoke-RestMethod 'https://v1.basketball.api-sports.io/leagues' -Method 'GET' -Headers $headers $response | ConvertTo-Json ``` ## Python `http.client` ```python import http.client conn = http.client.HTTPSConnection("v1.basketball.api-sports.io") headers = { 'x-apisports-key': "XxXxXxXxXxXxXxXxXxXxXxXx" } conn.request("GET", "/leagues", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` `Requests` ```python url = "https://v1.basketball.api-sports.io/leagues" payload={} headers = { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx', } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` ## Ruby `Net::HTTP` ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://v1.basketball.api-sports.io/leagues") 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-apisports-key"] = 'XxXxXxXxXxXxXxXxXxXxXxXx' response = http.request(request) puts response.read_body ``` ## Shell `Httpie` ```shell http --follow --timeout 3600 GET 'https://v1.basketball.api-sports.io/leagues' \ x-apisports-key:'XxXxXxXxXxXxXxXxXxXxXxXx' \ ``` `wget` ```shell wget --no-check-certificate --quiet \ --method GET \ --timeout=0 \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' \ 'https://v1.basketball.api-sports.io/leagues' ``` ## Swift `URLSession` ```swift import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif var semaphore = DispatchSemaphore (value: 0) var request = URLRequest(url: URL(string: "https://v1.basketball.api-sports.io/leagues")!,timeoutInterval: Double.infinity) request.addValue("XxXxXxXxXxXxXxXxXxXxXxXx", forHTTPHeaderField: "x-apisports-key") request.httpMethod = "GET" let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data else { print(String(describing: error)) semaphore.signal() return } print(String(data: data, encoding: .utf8)!) semaphore.signal() } task.resume() semaphore.wait() ``` # Changelog ### (1.5.6) - Endpoint `leagues` - Add field `coverage` - Endpoint `games` - Add endpoint `games/statistics/teams` - Add endpoint `games/statistics/players` - Add field `venue` - Add endpoint `players`
Continue with this provider
This provider-level handoff preserves only its public ID. No tool or business task is guessed; choose a current tool during rediscovery before setup can be treated as complete.
- Selected provider
- api_sports
- Selected tool
- Unknown — confirm during rediscovery
- Business task
- Unknown — confirm during rediscovery
- Catalog updated
- Unknown — confirm during rediscovery
Get odds from games or leagues. Pre-match odds are provided 1–7 days before the game.; Get odds from games or leagues. Pre-match odds are provided between 1 and 7 days before the game.; Get pre-match odds for rugby games or leagues with optional filtering by bookmaker or bet type.
Return the list of available odds for games. We provide pre-match odds between 1 and 7 days before the game. We keep a 7-day history *(The availability of odds may vary according to the games, seasons and bookmakers)* Parameters: This endpoint requires at least one of theses parameters : game. > Odds are updated four times a day
Get odds for volleyball games or leagues with optional filtering by bookmaker or bet type. Pre-match odds are provided between 1 and 7 days before the game.
Return the list of available odds for fights. We provide pre-match odds between 1 and 7 days before the fight. We keep a 7-day history *(The availability of odds may vary according to the fights, seasons and bookmakers)* Parameters: This endpoint requires at least one of theses parameters : fight, date. > Odds are updated four times a day
Get the list of pit stops made by all drivers during a race.
Get the list of pit stops made by all drivers during a race. > All the parameters of this endpoint can be used together.
Retrieve a list of basketball players with optional filtering by team, league, or search.; Get data about players. Requires at least one parameter.; Get player data with at least one parameter such as id, team, season, or search term.
Return a list of available players. The player id is unique across all competitions.
Return a list of available players with optional filtering by ID, name, team+season, or search term.; Return a list of available players. The player id is unique across all competitions.
Retrieve data about NBA players using filters such as ID, name, team, season, country, or search term. At least one parameter is required.
Return a list of available players. The player `id` are unique in the API and keep it among all the competitions in which they participate. Parameters: This endpoint requires at least one of theses parameters : id, team, name, search. > This endpoint is updated every day
Get data about players. The players `id` are unique in the API and players keep it among all the leagues/cups in which they participate. > This endpoint requires at least one parameter.
Return a set of data about the players. Requires at least one parameter: id, name, team, season, or search.
Return a set of data about the players. The players `id` are unique in the API and keep it among all the competitions in which they participate. *Not all data is available for all players.* Parameters: This endpoint requires at least one parameter. > This endpoint is updated every day
Get data about players. The player `id` are unique in the API and players keep it among all seasons. > This endpoint requires at least one parameter.
Return the statistics of a player for the whole season. Requires at least two parameters: id or team, and season.
Return the statistics of a player for the whole season. The statistics of the players are different depending on the positions they occupy in the formation, so they are grouped into different `groups`. Available Groups * Defense * Kicking * Passing * Punting * Receiving * Returning * Rushing * Scoring > Data for this endpoint start from 2022 season Parameters: This endpoint requires at least two parameters `id` or `team` and `season`. > This endpoint is updated every day
Get statistics for one or more NBA players based on player ID, game ID, team ID, or season. At least one parameter is required.
Return the statistics of a player for a given season. Parameters: This endpoint requires at least theses parameters : id, season. > This endpoint is updated every day
