### Fetch Hockey Leagues using C and libcurl Source: https://api-sports.io/documentation/hockey/v1/index This example shows how to fetch league data using the libcurl library in C. It initializes a curl handle, sets the request method to GET, specifies the URL, and adds the required API key header. Ensure libcurl is installed and linked. ```c CURL *curl; CURLcode res; c_url = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_easy_setopt(curl, CURLOPT_URL, "https://v1.hockey.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); } c_url_easy_cleanup(curl); ``` -------------------------------- ### Fetch Hockey Leagues using Java OkHttp and Unirest Source: https://api-sports.io/documentation/hockey/v1/index This section provides two Java examples for fetching league data. The first uses OkHttp to set up headers for a GET request. The second uses the Unirest library to directly make a GET request with the API key header and retrieve the response as a string. ```java var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; ``` ```java Unirest.setTimeouts(0, 0); HttpResponse response = Unirest.get("https://v1.hockey.api-sports.io/leagues") .header("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") .asString(); ``` -------------------------------- ### Fetch Hockey Leagues using cURL Source: https://api-sports.io/documentation/hockey/v1/index This example demonstrates how to fetch league data using the cURL command-line tool. It specifies the GET method, the API endpoint URL, and includes the necessary API key in the request headers. ```bash curl --request GET \ --url https://v1.hockey.api-sports.io/leagues \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' ``` -------------------------------- ### Fetch Hockey Leagues Data - Node.js Source: https://api-sports.io/documentation/hockey/v1/index This Node.js example shows how to make a GET request to the hockey leagues endpoint. It includes the API key in the request headers and logs the response. This is useful for backend Node.js applications. ```javascript const https = require('https'); const options = { hostname: 'v1.hockey.api-sports.io', port: 443, path: '/leagues', method: 'GET', headers: { 'x-apisports-key': 'XxXxXxXxXxXxXxXxXxXxXxXx' } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(JSON.parse(data)); }); }); req.on('error', (error) => { console.error(error); }); req.end(); ``` -------------------------------- ### Fetch Hockey Leagues using Ruby Net::HTTP Source: https://api-sports.io/documentation/hockey/v1/index This Ruby example uses the Net::HTTP library to make a GET request to the hockey API. It handles SSL verification and sets the necessary API key header before making the request and printing the response body. ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://v1.hockey.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 ``` -------------------------------- ### OCaml: Fetch Hockey Leagues with Cohttp Source: https://api-sports.io/documentation/hockey/v1/index Fetches hockey league data using the Cohttp library in OCaml. This example demonstrates making an asynchronous HTTP GET request with custom headers. Outputs the response body as a string. ```ocaml open Lwt open Cohttp open Cohttp_lwt_unix let reqBody = let uri = Uri.of_string "https://v1.hockey.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) ``` -------------------------------- ### Example Custom Translation JSON Structure Source: https://api-sports.io/documentation/hockey/v1/index Provides an example of the JSON structure required for custom translation files. This format allows for overriding default labels, translating missing terms, and adapting terminology for specific audiences. ```json { "all": "All", "live": "Now Live", "finished": "Completed", "scheduled": "Coming Up", "favorites": "Favorites", } ``` -------------------------------- ### Fetch Hockey Leagues using Python http.client Source: https://api-sports.io/documentation/hockey/v1/index This example demonstrates fetching hockey league data using Python's built-in http.client library. It establishes an HTTPS connection, sets the required API key header, sends a GET request, and prints the decoded response. ```python import http.client conn = http.client.HTTPSConnection("v1.hockey.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")) ``` -------------------------------- ### Fetch Hockey Leagues Data - cURL Source: https://api-sports.io/documentation/hockey/v1/index This cURL command shows how to retrieve a list of hockey leagues. It requires your API key in the 'x-apisports-key' header. This is a basic example to get started with the API. ```bash curl --request GET \ --url 'https://v1.hockey.api-sports.io/leagues' \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' ``` -------------------------------- ### Get All Available Bets (PHP) Source: https://api-sports.io/documentation/hockey/v1/index This PHP snippet demonstrates how to fetch all available bets using the http client. It sets the request URL to '/bets', specifies the GET method, and includes the required 'x-apisports-key' in the headers. The response body is then printed. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/bets'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch Hockey Leagues using Javascript Fetch, jQuery, and XHR Source: https://api-sports.io/documentation/hockey/v1/index This section offers three Javascript examples for retrieving league data. The 'Fetch' example uses the modern Fetch API. 'jQuery' demonstrates using $.ajax with specified settings. 'XHR' shows the traditional XMLHttpRequest approach, including setting up event listeners and request headers. ```javascript var myHeaders = new Headers(); myHeaders.append("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch("https://v1.hockey.api-sports.io/leagues", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` ```javascript var settings = { "url": "https://v1.hockey.api-sports.io/leagues", "method": "GET", "timeout": 0, "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx", }, }; $.ajax(settings).done(function (response) { console.log(response); }); ``` ```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.hockey.api-sports.io/leagues"); xhr.setRequestHeader("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx"); xhr.send(); ``` -------------------------------- ### GET /v1/leagues Source: https://api-sports.io/documentation/hockey/v1/index Retrieves a list of available hockey leagues. ```APIDOC ## GET /v1/leagues ### Description Retrieves a list of all supported hockey leagues. ### Method GET ### Endpoint /v1/leagues ### Parameters #### Query Parameters - **country** (string) - Optional - Filter leagues by country name or code. - **search** (string) - Optional - Filter leagues by name. - **season** (integer) - Optional - Filter leagues by season (e.g., 2019). ### Request Example ``` GET /v1/leagues?country=Canada&season=2019 ``` ### Response #### Success Response (200) - **results** (integer) - The number of leagues returned. - **response** (array) - An array of league objects. - **league** (object) - **id** (integer) - The unique identifier for the league. - **name** (string) - The name of the league. - **type** (string) - The type of the league (e.g., "League"). - **logo** (string) - The URL to the league's logo. - **country** (object) - **id** (integer) - The unique identifier for the country. - **name** (string) - The name of the country. - **code** (string) - The ISO code for the country. - **flag** (string) - The URL to the country's flag image. - **season** (integer) - The season the league data pertains to. - **season_id** (integer) - The unique identifier for the league season. #### Response Example ```json { "results": 1, "response": [ { "league": { "id": 3, "name": "OHL", "type": "League", "logo": "https://media.api-sports.io/hockey/leagues/3.png" }, "country": { "id": 4, "name": "Canada", "code": "CA", "flag": "https://media.api-sports.io/flags/ca.svg" }, "season": 2019, "season_id": 12345 } ] } ``` ``` -------------------------------- ### GET /standings/stages Source: https://api-sports.io/documentation/hockey/v1/index Retrieves the stages for a given league and season. ```APIDOC ## GET /standings/stages ### Description Retrieves the available stages for a league and season. ### Method GET ### Endpoint https://v1.hockey.api-sports.io/standings/stages ### Parameters #### Query Parameters - **league** (integer) - Required - The id of the league. - **season** (string) - Required - The season of the league (e.g., '2019'). #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key. ### Request Example ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/standings/stages'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ### Response #### Success Response (200) - **get** (string) - Endpoint name. - **parameters** (object) - Request parameters. - **league** (string) - The league ID used in the request. - **season** (string) - The season used in the request. - **errors** (array) - An array of errors, if any. - **results** (integer) - The number of results returned. - **response** (array) - An array of stage names (e.g., ["OHL"]). #### Response Example ```json { "get": "standings/stages", "parameters": { "league": "3", "season": "2019" }, "errors": [], "results": 1, "response": [ "OHL" ] } ``` ``` -------------------------------- ### GET /standings/groups Source: https://api-sports.io/documentation/hockey/v1/index Retrieves the available groups for a league and season. ```APIDOC ## GET /standings/groups ### Description Retrieves the list of available groups for a league to be used in the standings endpoint. ### Method GET ### Endpoint https://v1.hockey.api-sports.io/standings/groups ### Parameters #### Query Parameters - **league** (integer) - Required - The id of the league. - **season** (integer) - Required - The season of the league (e.g., '2019'). #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key. ### Request Example ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/standings/groups'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ### Response #### Success Response (200) - **get** (string) - Endpoint name. - **parameters** (object) - Request parameters. - **league** (string) - The league ID used in the request. - **season** (string) - The season used in the request. - **errors** (array) - An array of errors, if any. - **results** (integer) - The number of results returned. - **response** (array) - An array of group names (e.g., ["Western Conference", "Eastern Conference"]). #### Response Example ```json { "get": "standings/groups", "parameters": { "league": "3", "season": "2019" }, "errors": [], "results": 6, "response": [ "Western Conference", "Eastern Conference", "Central", "East", "West", "Midwest" ] } ``` ``` -------------------------------- ### GET /leagues Source: https://api-sports.io/documentation/hockey/v1/index Retrieves a list of available hockey leagues. Requires an API key for authentication. ```APIDOC ## GET /leagues ### Description Retrieves a list of available hockey leagues from the API. ### Method GET ### Endpoint https://v1.hockey.api-sports.io/leagues ### Parameters #### Query Parameters None #### Headers - **x-apisports-key** (string) - Required - Your API key for authentication. ### Request Example ```json { "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx" } } ``` ### Response #### Success Response (200) - **response** (object) - Contains league data. #### Response Example ```json { "response": [ { "league": { "id": 1, "name": "Test League", "type": "league", "logo": "https://media.api-sports.io/hockey/leagues/1.png" } } ] } ``` ``` -------------------------------- ### GET /v1/countries Source: https://api-sports.io/documentation/hockey/v1/index Retrieves a list of supported countries for hockey leagues and teams. ```APIDOC ## GET /v1/countries ### Description Retrieves a list of all supported countries available in the API. ### Method GET ### Endpoint /v1/countries ### Parameters #### Query Parameters - **search** (string) - Optional - Filter countries by name. ### Request Example ``` GET /v1/countries?search=Canada ``` ### Response #### Success Response (200) - **results** (integer) - The number of countries returned. - **response** (array) - An array of country objects. - **id** (integer) - The unique identifier for the country. - **name** (string) - The name of the country. - **code** (string) - The ISO code for the country. - **flag** (string) - The URL to the country's flag image. #### Response Example ```json { "results": 1, "response": [ { "id": 4, "name": "Canada", "code": "CA", "flag": "https://media.api-sports.io/flags/ca.svg" } ] } ``` ``` -------------------------------- ### GET /leagues Source: https://api-sports.io/documentation/hockey/v1/index Retrieves a list of available hockey leagues. This endpoint requires an API key for authentication. ```APIDOC ## GET /leagues ### Description Retrieves a list of available hockey leagues. This endpoint requires an API key for authentication. ### Method GET ### Endpoint /leagues ### Parameters #### Headers - **x-apisports-key** (string) - Required - Your API key for authentication. ### Request Example ```json { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx" } ``` ### Response #### Success Response (200) - **response** (object) - Contains league data. - **league** (object) - Details about the league. - **id** (integer) - The unique identifier for the league. - **name** (string) - The name of the league. - **type** (string) - The type of the league (e.g., "league", "national league"). - **logo** (string) - A URL to the league's logo. - **flag** (string) - A URL to the league's flag. - **season** (integer) - The current season year. - ** 2023-2024** (string) - Indicates if the season is active. - ** 2023-2024** (boolean) - Indicates if the season is currently active. #### Response Example ```json { "get": "leagues", "parameters": { "current": "true" }, "errors": [], "results": 1, "paging": { "current": 1, "total": 1 }, "response": [ { "league": { "id": 538, "name": "NHL", "type": "league", "logo": "https://media.api-sports.io/hockey/leagues/538.png", "flag": "https://media.api-sports.io/flags/us.svg", "season": 2023, " 2023-2024": "true" }, " 2023-2024": true } ] } ``` ``` -------------------------------- ### GET /games Source: https://api-sports.io/documentation/hockey/v1/index Retrieves a list of games based on various criteria like date, league, season, or team. ```APIDOC ## GET /games ### Description Retrieves a list of hockey games. You can filter games by ID, date, league, season, team, or timezone. Games are updated every 15 seconds. ### Method GET ### Endpoint https://v1.hockey.api-sports.io/games ### Parameters #### Query Parameters - **id** (integer) - Optional - The ID of the game. - **date** (string) - Optional - A valid date in YYYY-MM-DD format. - **league** (integer) - Optional - The ID of the league. - **season** (integer) - Optional - The season of the league (4 characters, e.g., '2019'). - **team** (integer) - Optional - The ID of the team. - **timezone** (string) - Optional - A valid timezone (e.g., 'Europe/London'). #### Header Parameters - **x-apisports-key** (string) - Required - Your API-SPORTS Key. ### Request Example ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/games'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'id' => '8279' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` ### Response #### Success Response (200) - **get** (string) - Endpoint name. - **parameters** (object) - Request parameters. - **errors** (array) - An array of errors, if any. - **results** (integer) - The number of results returned. - **response** (array) - An array of game objects. - **events** (boolean) - Indicates if events are available for this game. - **status** (string) - The current status of the game (e.g., "NS", "P1", "FT"). See documentation for full list of statuses. #### Response Example ```json { "get": "games", "parameters": { "id": "8279" }, "errors": [], "results": 1, "response": [ { "league": { "id": 57, "name": "NHL", "type": "league", "logo": "https://media.api-sports.io/hockey/leagues/57.png" }, "teams": { "home": { "id": 49, "name": "Boston Bruins", "logo": "https://media.api-sports.io/hockey/teams/49.png", "winner": true }, "away": { "id": 53, "name": "Dallas Stars", "logo": "https://media.api-sports.io/hockey/teams/53.png", "winner": false } }, "score": { "home": 3, "away": 2 }, "game": { "id": 8279, "season": "2023", "week": "Regular Season - 15", "date": "2023-11-20T00:00:00+00:00", "timezone": "America/New_York", "status": { "long": "Finished", "short": "FT", "elapsed": null } } } ] } ``` ``` -------------------------------- ### Fetch Hockey Leagues using Go Native HTTP Source: https://api-sports.io/documentation/hockey/v1/index This Go program utilizes the native `net/http` package to retrieve league data. It creates an HTTP client, constructs a GET request, adds the API key header, sends the request, and prints the response body. Error handling is included for request creation and execution. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://v1.hockey.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)) } ``` -------------------------------- ### PHP: Fetch Hockey Leagues with Http Source: https://api-sports.io/documentation/hockey/v1/index Fetches hockey league data using the http extension in PHP. This example demonstrates queuing and sending a request, then retrieving the response. Requires the 'http' extension. Outputs the response body. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/leagues'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Get Hockey League Standings Source: https://api-sports.io/documentation/hockey/v1/index Retrieves the current standings for a specified hockey league. This endpoint allows you to get detailed information about each team's performance within a league, including their position, games played, wins, losses, goals for and against, and overall points. ```APIDOC ## GET /v1/holidays ### Description Retrieves a list of holidays for a given country and year. Allows filtering by optional month. ### Method GET ### Endpoint `/v1/holidays` ### Parameters #### Query Parameters - **country** (string) - Required - The country code (e.g., 'CA', 'US'). - **year** (integer) - Required - The year for which to retrieve holidays. - **month** (integer) - Optional - The month (1-12) to filter holidays by. ### Request Example ```json { "example": "/v1/holidays?country=CA&year=2023&month=12" } ``` ### Response #### Success Response (200) - **holidays** (array) - A list of holiday objects. - **name** (string) - The name of the holiday. - **date** (string) - The date of the holiday in 'YYYY-MM-DD' format. - **country** (object) - Information about the country. - **code** (string) - The country code. - **name** (string) - The country name. - **type** (string) - The type of holiday (e.g., 'National', 'Local'). #### Response Example ```json { "response": [ { "name": "Christmas Day", "date": "2023-12-25", "country": { "code": "CA", "name": "Canada" }, "type": "National" } ] } ``` ``` -------------------------------- ### Get Timezone List - PHP Request Sample Source: https://api-sports.io/documentation/hockey/v1/index This PHP code snippet demonstrates how to make a GET request to the /timezone endpoint of the API-SPORTS Hockey v1 API to retrieve a list of available timezones. It includes setting the necessary headers, specifically the 'x-apisports-key'. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/timezone'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Apply Custom CSS Theme to Widget Source: https://api-sports.io/documentation/hockey/v1/index Demonstrates how to define custom CSS variables for a widget's theme using the `data-theme` attribute. This allows for overriding default styles like colors, fonts, and sizes. The example shows how to apply a custom theme named 'MyTheme' to an api-sports-widget. ```css api-sports-widget[data-theme="MyTheme"] { --primary-color: #18cfc0; --success-color: #2ecc58; --warning-color: #f39c12; --danger-color: #e74c3c; --light-color: #898989; --home-color: var(--primary-color); --away-color: #ffc107; --text-color: #333; --text-color-info: #333; --background-color: #fff; --primary-font-size: 0.72rem; --secondary-font-size: 0.75rem; --button-font-size: 0.8rem; --title-font-size: 0.9rem; --header-text-transform: uppercase; --button-text-transform: uppercase; --title-text-transform: uppercase; --border: 1px solid #95959530; --game-height: 2.3rem; --league-height: 2.35rem; --score-size: 2.25rem; --flag-size: 22px; --teams-logo-size: 18px; --teams-logo-size-xl: 5rem; --hover: rgba(200, 200, 200, 0.15); } ``` ```html
``` -------------------------------- ### Get Seasons List - PHP Request Sample Source: https://api-sports.io/documentation/hockey/v1/index This PHP code snippet shows how to fetch the list of available seasons from the API-SPORTS Hockey v1 API by making a GET request to the /seasons endpoint. Ensure you replace 'XxXxXxXxXxXxXxXxXxXxXxXx' with your actual API key. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/seasons'); $request->setRequestMethod('GET'); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Widget Configuration and Usage Source: https://api-sports.io/documentation/hockey/v1/index This section details how to configure and use various API Sports widgets, including setting API keys, sports types, target containers for dynamic content, and language preferences. ```APIDOC ## Widget Configuration and Usage ### Overview API Sports provides various widgets to display sports data. These widgets can be configured using custom HTML tags and attributes. ### Available Widgets - `games`: list of matches - `game`: details of a match - `team`: team profile - `player`: player profile - `standings`: league table - `league`: schedule - `leagues`: list of all leagues - `h2h`: historical head-to-head - Formula 1: `races`, `race`, `driver` - MMA: `fights`, `fight`, `fighter` Each widget adapts to the selected sport. ### Dynamic Targeting Certain widgets can dynamically open other widgets. This is controlled using `data-target-*` attributes. **Targeting Options:** - `modal`: Renders the widget in a modal window. - CSS selector (`#id` or `.class`): Injects the widget into a specific HTML element. **Available for General Sports:** - `data-target-game` - `data-target-standings` - `data-target-team` - `data-target-player` - `data-target-league` **Available for Formula 1:** - `data-target-race` - `data-target-ranking` - `data-target-driver` **Available for MMA:** - `data-target-fight` - `data-target-fighter` #### Example: Target a container by ID ```html
``` #### Example: Target using modal ```html ``` ### Language Configuration The `data-lang` attribute controls the widget's interface language. **Available Languages:** - `en` (English) - `fr` (French) - `es` (Spanish) - `it` (Italian) #### Example: Setting language ```html ``` #### Custom Translations Use `data-custom-lang` to load a custom JSON translation file for complete control over wording. This file must follow the internal key structure. If a key is defined in both `data-lang` and `data-custom-lang`, the custom file takes precedence. **Example Custom JSON Format:** ```json { "all": "All", "live": "Now Live", "finished": "Completed", "scheduled": "Coming Up", "favorites": "Favorites" } ``` #### Example: Using custom translations ```html ``` ### Caching Implementing a caching system can significantly reduce API request usage. Caching responses for a short duration (e.g., 60 seconds) ensures that subsequent requests within that period are served from the cache, minimizing daily request counts. ### Debugging To enable error messages within the widget and console, set the `data-show-errors` tag to `true`. Common errors include reaching the daily request limit, incorrect tag configurations, or an invalid API key. ``` -------------------------------- ### Target Widget to Modal Window (HTML) Source: https://api-sports.io/documentation/hockey/v1/index Illustrates how to configure a widget to open its content within a modal dialog using the 'data-target-*' attribute set to 'modal'. This is useful for displaying detailed information without navigating away from the current page. ```html ``` -------------------------------- ### GET /bookmakers Source: https://api-sports.io/documentation/hockey/v1/index Retrieve a list of available bookmakers for odds. ```APIDOC ## GET /bookmakers ### Description Retrieves a list of bookmakers from the API Sports Hockey v1. ### Method GET ### Endpoint /bookmakers ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://v1.hockey.api-sports.io/bookmakers" -H "x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx" ``` ### Response #### Success Response (200) - **response** (array) - An array of bookmaker objects, each containing an 'id' and 'name'. #### Response Example ```json { "get": "odds/bookmakers", "parameters": [], "errors": [], "results": 18, "response": [ { "id": 1, "name": "bwin" }, { "id": 2, "name": "10Bet" } ] } ``` ``` -------------------------------- ### Fetch Hockey Leagues Data - Python Source: https://api-sports.io/documentation/hockey/v1/index This Python script illustrates how to call the leagues endpoint of the API-HOCKEY. It shows how to include the necessary API key in the request headers. This example is useful for backend services or data analysis scripts. ```python import requests url = "https://v1.hockey.api-sports.io/leagues" headers = { 'x-apisports-key': "XxXxXxXxXxXxXxXxXxXxXxXx" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Fetch Hockey Leagues using PowerShell Source: https://api-sports.io/documentation/hockey/v1/index This snippet shows how to make a GET request to the /leagues endpoint using PowerShell's Invoke-RestMethod. It includes setting custom headers for API authentication and converting the response to JSON. ```powershell $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("x-apisports-key", "XxXxXxXxXxXxXxXxXxXxXxXx") $response = Invoke-RestMethod 'https://v1.hockey.api-sports.io/leagues' -Method 'GET' -Headers $headers $response | ConvertTo-Json ``` -------------------------------- ### GET /v1/standings Source: https://api-sports.io/documentation/hockey/v1/index Retrieves league standings for a given season and league. ```APIDOC ## GET /v1/standings ### Description Retrieves the current standings for a specific league and season. ### Method GET ### Endpoint /v1/standings ### Parameters #### Query Parameters - **season** (integer) - Required - The season to retrieve standings for (e.g., 2019). - **league** (integer) - Required - The ID of the league. ### Request Example ``` GET /v1/standings?season=2019&league=3 ``` ### Response #### Success Response (200) - **response** (array) - An array of team standing objects. - **team** (object) - **id** (integer) - The unique identifier for the team. - **name** (string) - The name of the team. - **logo** (string) - The URL to the team's logo. - **league** (object) - **id** (integer) - The unique identifier for the league. - **name** (string) - The name of the league. - **type** (string) - The type of the league. - **logo** (string) - The URL to the league's logo. - **season** (integer) - The season of the league. - **country** (object) - **id** (integer) - The unique identifier for the country. - **name** (string) - The name of the country. - **code** (string) - The ISO code for the country. - **flag** (string) - The URL to the country's flag image. - **games** (object) - **played** (integer) - Number of games played. - **win** (object) - **total** (integer) - Total wins. - **percentage** (string) - Win percentage. - **lose** (object) - **total** (integer) - Total losses. - **percentage** (string) - Loss percentage. - **win_overtime** (object) - **total** (integer) - Total overtime wins. - **percentage** (string) - Overtime win percentage. - **lose_overtime** (object) - **total** (integer) - Total overtime losses. - **percentage** (string) - Overtime loss percentage. - **goals** (object) - **for** (integer) - Goals scored. - **against** (integer) - Goals conceded. - **points** (integer) - Total points. - **form** (string) - Recent form of the team (e.g., "LLWWW"). - **description** (string|null) - Additional description for the team's standing (e.g., playoff qualification). #### Response Example ```json [ { "position": 1, "stage": "OHL", "group": { "name": "Central" }, "team": { "id": 36, "name": "Sudbury Wolves", "logo": "https://media.api-sports.io/hockey/teams/36.png" }, "league": { "id": 3, "name": "OHL", "type": "League", "logo": "https://media.api-sports.io/hockey/leagues/3.png", "season": 2019 }, "country": { "id": 4, "name": "Canada", "code": "CA", "flag": "https://media.api-sports.io/flags/ca.svg" }, "games": { "played": 63, "win": { "total": 29, "percentage": "0.460" }, "win_overtime": { "total": 5, "percentage": "0.079" }, "lose": { "total": 27, "percentage": "0.429" }, "lose_overtime": { "total": 2, "percentage": "0.032" } }, "goals": { "for": 259, "against": 240 }, "points": 70, "form": "WLWLOW", "description": "Promotion - OHL (Play Offs)" } ] ``` ``` -------------------------------- ### Fetch Hockey Leagues Data - Javascript Source: https://api-sports.io/documentation/hockey/v1/index This Javascript snippet demonstrates how to fetch hockey league data using the API. It includes setting the API key in the request header. This example is suitable for web applications. ```javascript const settings = { "async": true, "crossDomain": true, "url": "https://v1.hockey.api-sports.io/leagues", "method": "GET", "headers": { "x-apisports-key": "XxXxXxXxXxXxXxXxXxXxXxXx" } } $.ajax(settings).done(function (response) { console.log(response); }); ``` -------------------------------- ### Get Hockey Game Events Request Sample (PHP) Source: https://api-sports.io/documentation/hockey/v1/index This PHP code snippet demonstrates how to make a GET request to the /games/events endpoint of the API-Sports Hockey v1. It requires the 'game' ID as a query parameter and includes an API key in the headers for authentication. The response body containing event data is then output. ```php $client = new http\Client; $request = new http\Client\Request; $request->setRequestUrl('https://v1.hockey.api-sports.io/games/events'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array( 'game' => '8279' ))); $request->setHeaders(array( 'x-apisports-key' => 'XxXxXxXxXxXxXxXxXxXxXxXx' )); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody(); ``` -------------------------------- ### Fetch Hockey Leagues using Shell wget Source: https://api-sports.io/documentation/hockey/v1/index This shell command uses wget to retrieve hockey league data. It disables certificate checking, sets a timeout, specifies the GET method, includes the API key header, and provides the target URL. ```shell wget --no-check-certificate --quiet \ --method GET \ --timeout=0 \ --header 'x-apisports-key: XxXxXxXxXxXxXxXxXxXxXxXx' \ 'https://v1.hockey.api-sports.io/leagues' ```