### Get Latest Updated Fixtures - Example Response Source: https://context7_llms An example of the JSON response when successfully querying for the latest updated fixtures. The response contains a 'data' array, where each object represents a fixture with detailed information such as IDs, names, starting times, and status. ```json { "data": [ { "id": 19238160, "sport_id": 1, "league_id": 1412, "season_id": 22988, "stage_id": 77469045, "group_id": null, "aggregate_id": null, "round_id": null, "state_id": 1, "venue_id": null, "name": "Tersana vs El Gounah", "starting_at": "2024-08-08 15:00:00", "result_info": null, "leg": "1/1", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1723129200 }, { "id": 19238159, "sport_id": 1, "league_id": 1412, "season_id": 22988, "stage_id": 77469045, "group_id": null, "aggregate_id": null, "round_id": null, "state_id": 1, "venue_id": 4568, "name": "Pyramids FC vs Abu Qir Semad", "starting_at": "2024-08-08 15:00:00", "result_info": null, "leg": "1/1", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1723129200 } ] } ``` -------------------------------- ### GET State by ID - Example Response Source: https://context7_llms An example of the JSON response when successfully retrieving state information. It includes fields such as id, state, name, short_name, and developer_name. ```json { "data": [ { "id": 5, "state": "FT", "name": "Full Time", "short_name": "FT", "developer_name": "FT" } ] } ``` -------------------------------- ### Get All Leagues - Example Response Source: https://context7_llms An example JSON response demonstrating the structure of data returned when fetching all leagues. Each league object contains details such as ID, name, active status, and image path. ```json { "data": [ { "id": 271, "sport_id": 1, "country_id": 320, "name": "Superliga", "active": true, "short_code": "DNK SL", "image_path": "https://cdn.sportmonks.com/images/soccer/leagues/271.png", "type": "league", "sub_type": "domestic", "last_played_at": "2024-08-05 17:00:00", "category": 2, "has_jerseys": false }, { "id": 501, "sport_id": 1, "country_id": 1161, "name": "Premiership", "active": true, "short_code": "SCO P", "image_path": "https://cdn.sportmonks.com/images/soccer/leagues/501.png", "type": "league", "sub_type": "domestic", "last_played_at": "2024-08-05 19:00:00", "category": 2, "has_jerseys": false } ] } ``` -------------------------------- ### Get Fixture Statistics with Ball Possession Source: https://docs.sportmonks.com/football/tutorials-and-guides/tutorials/filter-and-select-fields/filtering This example demonstrates how to retrieve specific fixture statistics, such as ball possession, for a given fixture. ```APIDOC ## GET /football/fixtures/{id} ### Description Retrieve detailed statistics for a specific fixture, including filtering by event types and statistic types like ball possession. ### Method GET ### Endpoint /football/fixtures/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the fixture. #### Query Parameters - **api_token** (string) - Required - Your Sportmonks API token. - **include** (string) - Optional - Comma-separated list of related resources to include (e.g., `events;statistics.type`). - **filters** (string) - Optional - Comma-separated list of filters. Use `eventTypes:{ids}` for event types and `fixtureStatisticTypes:{ids}` for statistic types. For ball possession, the ID is 45. ### Request Example ``` https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events;statistics.type&filters=eventTypes:18,14;fixtureStatisticTypes:45 ``` ### Response #### Success Response (200) - **id** (integer) - The fixture ID. - **name** (string) - The name of the fixture. - **statistics** (array) - An array of statistic objects, each containing details like type name and value. #### Response Example ```json { "data": [ { "id": 18535517, "name": "Celtic vs Rangers", "statistics": [ { "type_id": 45, "name": "Ball Possession", "value": "60%" } ] } ] } ``` ``` -------------------------------- ### JavaScript Example for Bulk and Incremental Sync Source: https://context7_llms Pseudocode example demonstrating a strategy for initial bulk loading followed by an incremental sync loop. ```APIDOC ## Developer Notes & Examples ### Description This section provides a pseudocode example for implementing a bulk load followed by an incremental sync strategy. ### Language JavaScript (Pseudocode) ### Code Example ```javascript // Step 1: bulk load all via pages for (let page = 1; ; page++) { let resp = await fetchEndpoint({ include: null, filters: `populate;page:${page}` }) if (!resp.data.length) break saveToDb(resp.data) } // Step 2: start incremental sync loop let lastMaxId = getMaxIdFromDb() setInterval(async () => { let resp = await fetchEndpoint({ include: null, filters: `populate;idAfter:${lastMaxId}` }) if (resp.data.length) { saveToDb(resp.data) lastMaxId = getMaxIdFromDb() } }, pollIntervalMs) ``` ### Notes - **Concurrent paging**: Pages can be fetched in parallel after the initial `idAfter` and `populate` call. - **Edge case (out-of-order IDs)**: Periodically run a full sync of reference entities to catch anomalies. - **Empty result handling**: An empty result from `idAfter` indicates no new data. Monitor for long streaks of empty results. ``` -------------------------------- ### Fetch Football Fixtures via HTTP Request (Ruby, Python, PHP, Java, Node.js, Go) Source: https://context7_llms Demonstrates making an HTTP GET request to the Sportmonks API's football fixtures endpoint. It requires an API token for authentication. The examples show how to handle the request and response in different languages, including setting up the connection, sending the request, and processing the JSON response. Dependencies vary by language, including libraries like `net/http` in Ruby, `http.client` in Python, `curl` in PHP, OkHttpClient in Java, `unirest` in Node.js, and the standard `net/http` package in Go. ```ruby require "uri" require "net/http" url = URI("https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body ``` ```python import http.client conn = http.client.HTTPSConnection("api.sportmonks.com") payload = '' headers = {} conn.request("GET", "/v3/football/fixtures?api_token=YOUR_TOKEN", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```php 'https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN', 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', )); $response = curl_exec($curl); curl_close($curl); echo $response ``` ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN") .method("GET", null) .build(); Response response = client.newCall(request).execute() ``` ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } 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)) } ``` -------------------------------- ### GET Fixtures by Date - Example Response Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/fixtures/get-fixtures-by-date This is an example JSON response from the Sportmonks Football API when requesting fixtures for a specific date. It includes details for each fixture such as ID, league, season, starting time, and results. ```json { "data": [ { "id": 19146700, "sport_id": 1, "league_id": 501, "season_id": 23690, "stage_id": 77471570, "group_id": null, "aggregate_id": null, "round_id": 340573, "state_id": 5, "venue_id": 8879, "name": "St. Mirren vs Hibernian", "starting_at": "2024-08-04 14:00:00", "result_info": "St. Mirren won after full-time.", "leg": "1/1", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1722780000 }, { "id": 19146701, "sport_id": 1, "league_id": 501, "season_id": 23690, "stage_id": 77471570, "group_id": null, "aggregate_id": null, "round_id": 340573, "state_id": 5, "venue_id": 8909, "name": "Celtic vs Kilmarnock", "starting_at": "2024-08-04 15:30:00", "result_info": "Celtic won after full-time.", "leg": "1/1", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1722785400 } ] } ``` -------------------------------- ### Bulk and Incremental Data Sync Strategy (JavaScript) Source: https://context7_llms Demonstrates a two-step process for syncing data: an initial bulk load of all data using pagination and `filters=populate`, followed by a continuous incremental sync using `idAfter` to fetch only new records. This approach ensures efficient data retrieval and updates. ```javascript async function syncData() { // Step 1: bulk load all via pages for (let page = 1; ; page++) { let resp = await fetchEndpoint({ include: null, filters: `populate;page:${page}` }); if (!resp.data.length) break; saveToDb(resp.data); } // Step 2: start incremental sync loop let lastMaxId = getMaxIdFromDb(); setInterval(async () => { let resp = await fetchEndpoint({ include: null, filters: `populate;idAfter:${lastMaxId}` }); if (resp.data.length) { saveToDb(resp.data); lastMaxId = getMaxIdFromDb(); } }, pollIntervalMs); } // Placeholder functions for demonstration async function fetchEndpoint(options) { // Replace with actual API call console.log('Fetching with options:', options); // Simulate response return { data: [] // Replace with actual data }; } function saveToDb(data) { // Replace with actual database save logic console.log('Saving to DB:', data.length, 'records'); } function getMaxIdFromDb() { // Replace with logic to get the max ID from your database return 0; } const pollIntervalMs = 60000; // Example: poll every minute ``` -------------------------------- ### GET Past Fixtures by TV Station ID - Example Response Source: https://context7_llms An example of the JSON response when requesting past fixtures by TV station ID. The response contains a 'data' array, where each object represents a fixture with its details, including IDs, names, starting times, and results. ```json { "data": [ { "id": 19190779, "sport_id": 1, "league_id": 654, "season_id": 23161, "stage_id": 77469785, "group_id": null, "aggregate_id": 54865, "round_id": null, "state_id": 8, "venue_id": 1718, "name": "Grêmio vs Corinthians", "starting_at": "2024-08-08 00:30:00", "result_info": "Grêmio won after penalties.", "leg": "2/2", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1723077000 }, { "id": 19190781, "sport_id": 1, "league_id": 654, "season_id": 23161, "stage_id": 77469785, "group_id": null, "aggregate_id": 54865, "round_id": null, "state_id": 5, "venue_id": 392, "name": "Fluminense vs Juventude", "starting_at": "2024-08-08 00:30:00", "result_info": "Game ended in draw.", "leg": "2/2", "details": null, "length": 90, "placeholder": false, "has_odds": true, "has_premium_odds": true, "starting_at_timestamp": 1723077000 } ] } ``` -------------------------------- ### Get Topscorers by Season ID - Node.js Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/topscorers/get-topscorers-by-season-id Fetches topscorer data for a season from the Sportmonks API using the 'unirest' library. This Node.js example makes a GET request and logs the raw response body to the console. Requires the 'unirest' package to be installed. ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/v3/football/topscorers/seasons/{ID}?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` -------------------------------- ### Making Your First Request Source: https://context7_llms Guide on how to construct your first request to the Sportmonks API, including base URL and authentication. ```APIDOC ## Making Your First Request Now that all prerequisites have been fulfilled, we’re ready to send our first request to the API! ### Prerequisites Before being able to make a request, you need to create your account in [MySportmonks](https://www.my.sportmonks.com). Here you can create your personal API token, which you need to [authenticate](https://docs.sportmonks.com/football/welcome/authentication) your requests. You can use the free plan or choose one of the various plans and data features of Sportmonks. ### Request Components The request consists of the following components: * The base URL * A path parameter, in this example, we use *fixtures* * Optional: Query string parameters, to filter on enrich your requests. * And finally, your API token #### Base URL In this example we're using the [fixtures endpoint](https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/fixtures). The base URL of the fixtures endpoint is: ```javascript https://api.sportmonks.com/v3/football ``` ### Security Best Practice Directly integrating an API into the frontend of a web application can be risky as it can expose sensitive information, such as your Sportmonks API token, to potential security breaches. To avoid this, it is best practice to use a middleware, such as a backend or proxy server, to handle all communication between the frontend and the API. This middleware acts as an intermediary, making sure your API tokens are stored securely and not exposed to users. Using middleware makes it much harder for malicious actors to access sensitive information, keeping your application more secure overall. ``` -------------------------------- ### GET All Premium Markets Example Source: https://docs.sportmonks.com/football/llms-full.txt/1 This example demonstrates how to make a GET request to retrieve all available premium markets. It uses the base URL and includes example parameters for filtering and selecting fields. ```javascript https://api.sportmonks.com/v3/odds/markets/premium?api_token=YOUR_TOKEN&include=participants;events&select=id,name&filters=IdAfter:12&order=desc ``` -------------------------------- ### Nested Includes Example (URL) Source: https://context7_llms This example shows how to perform multi-level or nested includes to fetch data from deeply related entities. The syntax uses dots (`.`) to chain includes, allowing access to relations within relations. ```url ?api_token=…&include=events.player.country:name ``` -------------------------------- ### Base Field Selection Example (URL) Source: https://context7_llms This URL parameter example shows how to use `&select=` to fetch only specific fields from the base entity, reducing response payload size. It is a common pattern for optimizing API requests. ```url ?api_token=…&select=name,starting_at ``` -------------------------------- ### Fetch Football Schedules by Season ID - Node.js Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/schedules/get-schedules-by-season-id This Node.js example uses the 'unirest' library to make a GET request to the Sportmonks API for football season schedules. It logs the raw response body to the console. Remember to install 'unirest' (npm install unirest) and replace '{id}' and 'YOUR_TOKEN' with your specific API details. ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/v3/football/schedules/seasons/{id}?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` -------------------------------- ### Including Related Entities Example (URL) Source: https://context7_llms This example demonstrates the use of the `&include=` parameter to fetch related data objects along with the base entity. This allows for more comprehensive data retrieval in a single API call. ```url ?api_token=…&include=lineups,events ``` -------------------------------- ### Fetch Current League Team Data (Node.js) Source: https://context7_llms This Node.js example uses the 'unirest' library to make a GET request to the Sportmonks API for current team data. It logs any errors or the raw response body to the console. Ensure you have installed 'unirest' via npm. ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/api/v3/football/leagues/teams/{ID}/current?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` -------------------------------- ### Polling Workflow Example Source: https://context7_llms Illustrates a typical polling workflow for the Live Scores API over a period of time, showing API calls, cache comparisons, and updates. It demonstrates handling of fixture updates and empty responses. ```pseudocode Let polling interval = 6 seconds T = now → GET latest → returns fixtures A, B → Compare with cache → apply updates for changed ones → Update cache T + 6s → GET latest → returns fixtures B, C → Process B (if changed), process C → Update cache T + 12s → GET latest → returns [] → No changes, skip processing → Optional: if many empties, slow poll rate ``` -------------------------------- ### Get Stage by ID - Example Response Source: https://context7_llms An example JSON response for the 'Get Stage by ID' endpoint. It includes details about a stage, such as its ID, associated sport, league, season, name, and active status. ```json { "data": { "id": 77457866, "sport_id": 1, "league_id": 501, "season_id": 19735, "type_id": 223, "name": "1st Phase", "sort_order": 1, "finished": false, "is_current": true, "starting_at": "2022-07-30", "ending_at": "2023-04-22", "games_in_current_week": true } } ``` -------------------------------- ### GET Bookmaker by ID Example Request Source: https://docs.sportmonks.com/football/tutorials-and-guides/tutorials/odds-and-predictions/bookmakers An example of a request to get information for the bookmaker 'bet365' with ID 2. It includes the specific bookmaker ID in the URL and the API token for authentication. ```http https://api.sportmonks.com/v3/odds/bookmakers/2?api_token=YOUR_TOKEN ``` -------------------------------- ### Example Response for Live Leagues Source: https://context7_llms An example JSON response showcasing the structure of data returned for a live league. This includes league ID, sport ID, country ID, name, active status, short code, image path, type, sub-type, last played date, and category. ```json { "data": { "id": 501, "sport_id": 1, "country_id": 1161, "name": "Premiership", "active": true, "short_code": "SCO P", "image_path": "https://cdn.sportmonks.com/images/soccer/leagues/501.png", "type": "league", "sub_type": "domestic", "last_played_at": "2024-08-05 19:00:00", "category": 2, "has_jerseys": false } } ``` -------------------------------- ### Retrieve League with Current Season and Stages (HTTP) Source: https://context7_llms This example demonstrates how to fetch league information along with its current season and associated stages by using the 'include' parameter in an HTTP GET request. It utilizes a simple HTTP GET request and requires an API token for authentication. ```http GET /v3/football/leagues/501?api_token=YOUR_TOKEN&include=currentSeason.stages ``` -------------------------------- ### GET Referees by Country ID - Example Response Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/referees/get-referees-by-country-id An example JSON response structure for the 'GET Referees by Country ID' API call. It includes a 'data' array containing referee objects with their details. ```json { "data": [ { "id": 13578, "sport_id": 1, "country_id": 462, "city_id": null, "common_name": "S. Finch", "firstname": "Stephen", "lastname": "Finch", "name": "Stephen Finch", "display_name": "Stephen Finch", "image_path": "https://cdn.sportmonks.com/images/soccer/placeholder.png", "height": null, "weight": null, "date_of_birth": null, "gender": null } ] } ``` -------------------------------- ### Get Leagues by Fixture Date - Example Response Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/leagues/get-leagues-by-fixture-date This is an example JSON response for the 'Get Leagues by Fixture Date' endpoint. It includes league details such as ID, name, country, and last played date. ```json { "data": [ { "id": 271, "sport_id": 1, "country_id": 320, "name": "Superliga", "active": true, "short_code": "DNK SL", "image_path": "https://cdn.sportmonks.com/images/soccer/leagues/271.png", "type": "league", "sub_type": "domestic", "last_played_at": "2024-08-05 17:00:00", "category": 2, "has_jerseys": false }, { "id": 501, "sport_id": 1, "country_id": 1161, "name": "Premiership", "active": true, "short_code": "SCO P", "image_path": "https://cdn.sportmonks.com/images/soccer/leagues/501.png", "type": "league", "sub_type": "domestic", "last_played_at": "2024-08-05 19:00:00", "category": 2, "has_jerseys": false } ] } ``` -------------------------------- ### Sort Fixtures by Starting Date (Descending) Source: https://context7_llms Demonstrates how to sort fixture data in descending order based on their starting date and time. This utilizes the `sortBy` and `order` query parameters in the API request. ```bash https://api.sportmonks.com/v3/football/fixtures?sortBy=starting_at&order=desc ``` -------------------------------- ### Real-time and Event-Driven Applications Source: https://context7_llms Build applications that react instantly to live match events, such as sending notifications, displaying live commentary, or showing head-to-head statistics. ```APIDOC ## Real-time and Event-Driven Apps ### Description Build apps that respond instantly to events or changes in matches. ### Use Cases * **Match alerts & notifications** * **Live commentary widgets** * **Head-to-head live comparison** ### Endpoint Examples #### Get Currently Live Matches * **Method**: GET * **Endpoint**: `/livescores/inplay` * **Description**: Gets all matches that are currently in progress. #### Get Detailed Match Data * **Method**: GET * **Endpoint**: `/fixtures/{fixture_id}` * **Description**: Get detailed event and stat data for a specific match. * **Query Parameters**: * `include` (string) - Optional - Comma-separated list of data to include (e.g., `events,statistics,participants`). #### Get Recently Updated Matches * **Method**: GET * **Endpoint**: `/livescores/latest` * **Description**: Get matches that have been updated in the last few seconds, suitable for polling. ``` -------------------------------- ### Get Match Facts by Date Range Source: https://docs.sportmonks.com/football/llms-full.txt/1 This example demonstrates how to fetch match facts for fixtures within a specified date range. It requires a valid API token and specifies the start and end dates in the URL. The response includes detailed match fact data. ```javascript https://api.sportmonks.com/v3/football/match-facts/fixtures/between/START_DATE/END_DATE ``` -------------------------------- ### Filtering Overview Source: https://context7_llms General guidance on using filters, including a link to tutorials and an endpoint for discovering available filters. ```APIDOC ## Filtering Overview For detailed information on how to use filters, please refer to our tutorial on [filtering](https://docs.sportmonks.com/football2/api/request-options/filtering). To discover which filters are available, you can check the following [endpoint](https://app.gitbook.com/s/z0kWjB5EvZvqGsozw8vP/endpoints/filters/get-all-entity-filters): ``` https://api.sportmonks.com/v3/my/filters/entity?api_token=YOUR_TOKEN ``` ``` -------------------------------- ### Get Team by Season Example (Ruby) Source: https://docs.sportmonks.com/football/llms-full.txt/1 Example Ruby code to fetch team data for a specific season. ```APIDOC ## GET /v3/football/teams/seasons/{ID} ### Description Fetch team data for a specific season. ### Method GET ### Endpoint `/v3/football/teams/seasons/{ID}` ### Path Parameters - **ID** (integer) - Required - The ID of the season. ### Query Parameters - **api_token** (string) - Required - Your API token. ### Request Example (Ruby) ```ruby require "uri" require "net/http" url = URI("https://api.sportmonks.com/v3/football/teams/seasons/{ID}?api_token=YOUR_TOKEN") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body ``` ``` -------------------------------- ### Example Response for GET Schedules by Season ID Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/schedules/get-schedules-by-season-id This is an example JSON response structure for the 'GET Schedules by Season ID' endpoint. It details the data format for schedules, including rounds, fixtures, participants, and scores. The response provides comprehensive match information. ```JSON { "data": [ { "id": 77457866, "sport_id": 1, "league_id": 501, "season_id": 19735, "type_id": 223, "name": "1st Phase", "sort_order": 1, "finished": false, "is_current": true, "starting_at": "2022-07-30", "ending_at": "2023-04-22", "games_in_current_week": true, "rounds": [ { "id": 274714, "sport_id": 1, "league_id": 501, "season_id": 19735, "stage_id": 77457866, "name": "1", "finished": true, "is_current": false, "starting_at": "2022-07-30", "ending_at": "2022-07-31", "games_in_current_week": false, "fixtures": [ { "id": 18535488, "sport_id": 1, "league_id": 501, "season_id": 19735, "stage_id": 77457866, "group_id": null, "aggregate_id": null, "round_id": 274714, "state_id": 5, "venue_id": 336296, "name": "Hearts vs Ross County", "starting_at": "2022-07-30 14:00:00", "result_info": "Hearts won after full-time.", "leg": "1/1", "details": null, "length": 90, "placeholder": false, "last_processed_at": "2023-02-17 10:19:56", "has_odds": true, "starting_at_timestamp": 1659189600, "participants": [ { "id": 314, "sport_id": 1, "country_id": 1161, "venue_id": 336296, "gender": "male", "name": "Hearts", "short_code": null, "image_path": "https://cdn.sportmonks.com/images/soccer/teams/26/314.png", "founded": 1874, "type": "domestic", "placeholder": false, "last_played_at": "2023-02-19 12:00:00", "meta": { "location": "home", "winner": true, "position": 6 } }, { "id": 246, "sport_id": 1, "country_id": 1161, "venue_id": 8908, "gender": "male", "name": "Ross County", "short_code": "RSC", "image_path": "https://cdn.sportmonks.com/images/soccer/teams/22/246.png", "founded": 1929, "type": "domestic", "placeholder": false, "last_played_at": "2023-02-25 15:00:00", "meta": { "location": "away", "winner": false, "position": 10 } } ], "scores": [ { "id": 11316594, "fixture_id": 18535488, "type_id": 1, "participant_id": 314, "score": { "goals": 0, "participant": "home" }, "description": "1ST_HALF" }, { "id": 11316595, "fixture_id": 18535488, "type_id": 1, "participant_id": 246, "score": { "goals": 0, "participant": "away" }, "description": "1ST_HALF" }, { "id": 11316596, "fixture_id": 18535488, "type_id": 2, "participant_id": 314, "score": { "goals": 2, "participant": "home" }, "description": "2ND_HALF" }, { "id": 11316597, "fixture_id": 18535488, "type_id": 2, "participant_id": 246, "score": { "goals": 1, "participant": "away" }, "description": "2ND_HALF" }, { "id": 11316598, "fixture_id": 18535488, "type_id": 1525, "participant_id": 314, "score": { "goals": 2, "participant": "home" }, "description": "CURRENT" }, { "id": 11316599, "fixture_id": 18535488, "type_id": 1525, "participant_id": 246, "score": { "goals": 1, "participant": "away" }, "description": "CURRENT" } ] } ] } ] } ] } ``` -------------------------------- ### Fetch Football League Data from Sportmonks API Source: https://context7_llms These examples demonstrate how to make a GET request to the Sportmonks API to retrieve information about a specific football league. Replace `{ID}` with the league's ID and `YOUR_TOKEN` with your actual API token. The code handles making the HTTP request and printing the response body. Ensure you have the necessary libraries installed for each language. ```ruby require "uri" require "net/http" url = URI("https://api.sportmonks.com/v3/football/leagues/{ID}?api_token=YOUR_TOKEN") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body ``` ```python import http.client conn = http.client.HTTPSConnection("api.sportmonks.com") payload = '' headers = {} conn.request("GET", "/api/v3/football/leagues/{ID}?api_token=YOUR_TOKEN", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```php 'https://api.sportmonks.com/api/v3/football/leagues/{ID}?api_token=YOUR_TOKEN', 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', )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.sportmonks.com/api/v3/football/leagues/{ID}?api_token=YOUR_TOKEN") .method("GET", null) .build(); Response response = client.newCall(request).execute(); ``` ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/api/v3/football/leagues/{ID}?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.sportmonks.com/api/v3/football/leagues/{ID}?api_token=YOUR_TOKEN" method := "GET" client := &http.Client { } req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } 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)) } ``` -------------------------------- ### Get All Football Transfers Source: https://docs.sportmonks.com/football/llms-full.txt/1 This section provides code examples in various programming languages to fetch a list of all football transfers from the Sportmonks API. It includes examples for Ruby, Python, PHP, Java, Node.js, and Go, demonstrating how to make a GET request to the transfers endpoint. ```ruby require "uri" require "net/http" url = URI("https://api.sportmonks.com/v3/football/transfers?api_token=YOUR_TOKEN") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Get.new(url) response = https.request(request) puts response.read_body ``` ```python import http.client conn = http.client.HTTPSConnection("api.sportmonks.com") payload = '' headers = {} conn.request("GET", "/v3/football/transfers?api_token=YOUR_TOKEN", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://api.sportmonks.com/v3/football/transfers?api_token=YOUR_TOKEN'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_ENCODING, ''); curl_setopt($curl, CURLOPT_MAXREDIRS, 10); curl_setopt($curl, CURLOPT_TIMEOUT, 0); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET'); $response = curl_exec($curl); curl_close($curl); echo $response; ``` ```java OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://api.sportmonks.com/v3/football/transfers?api_token=YOUR_TOKEN") .method("GET", null) .build(); Response response = client.newCall(request).execute(); ``` ```javascript var unirest = require('unirest'); var req = unirest('GET', 'https://api.sportmonks.com/v3/football/transfers?api_token=YOUR_TOKEN') .end(function (res) { if (res.error) throw new Error(res.error); console.log(res.raw_body); }); ``` ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.sportmonks.com/v3/football/transfers?api_token=YOUR_TOKEN" method := "GET" client := &http.Client {} req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } 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)) } ``` -------------------------------- ### Enhance Betting Platforms with Odds Data Source: https://context7_llms Leverage real-time odds and match data for betting platforms. Fetch pre-match and live odds, and combine with match statistics for enriched betting features. Precision with includes and filters is crucial to minimize data overhead and respect rate limits. ```Bash GET /v3/football/odds?market_ids=1,2,3 GET /v3/football/inplayOdds?fixture_ids=100,101 ``` -------------------------------- ### GET Expected by Player - Example Response Data Source: https://docs.sportmonks.com/football/llms-full.txt/1 This example demonstrates the structure of data returned by the 'GET Expected by Player' endpoint. Each object represents an expected value for a player in a specific fixture and lineup, including IDs for fixture, player, team, and lineup, along with the calculated 'value'. ```json { "data": [ { "id": 1064853093, "fixture_id": 19076535, "player_id": 77908, "team_id": 238626, "lineup_id": 8076889919, "type_id": 5304, "data": { "value": 0.0295 } }, { "id": 1064853094, "fixture_id": 19076535, "player_id": 37389571, "team_id": 238626, "lineup_id": 8076889917, "type_id": 5304, "data": { "value": 0.0496 } } ] } ``` -------------------------------- ### Get Football Transfers Between Date Range (JavaScript) Source: https://docs.sportmonks.com/football/llms-full.txt/1 This snippet shows how to retrieve football transfers that occurred between a specified start date and end date using the Sportmonks API. The dates must be in 'YYYY-MM-DD' format, and the maximum allowed range is 31 days. The example uses a JavaScript code block to illustrate the base URL structure. ```javascript https://api.sportmonks.com/v3/football/transfers/between/{startDate}/{endDate} ``` -------------------------------- ### Fetch Inplay Odds by Fixture and Market (Go) Source: https://docs.sportmonks.com/football/llms-full.txt/1 This Go code snippet shows how to fetch inplay odds using the standard net/http package. It creates an HTTP client, constructs a GET request, sends it, reads the response body, and prints it. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://api.sportmonks.com/v3/football/odds/inplay/fixtures/{ID}/bookmakers/{ID}?api_token=YOUR_TOKEN" method := "GET" client := &http.Client {} req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } 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)) } ``` -------------------------------- ### GET Topscorers by Season ID - Example Response Source: https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/topscorers/get-topscorers-by-season-id This is an example JSON response from the 'GET Topscorers by Season ID' endpoint. It shows the structure of the data returned, including 'data' array with topscorer details like id, season_id, player_id, type_id, position, total, and participant_id. ```json { "data": [ { "id": 1540848, "season_id": 19735, "player_id": 20708316, "type_id": 83, "position": 1, "total": 2, "participant_id": 314 }, { "id": 1540849, "season_id": 19735, "player_id": 123659, "type_id": 83, "position": 2, "total": 2, "participant_id": 273 } ] } ```