### PHP Request Example for Searching Horses Source: https://api.theracingapi.com/documentation/index Shows how to search for horses using PHP with cURL. This example sets up basic authentication and makes a GET request to the search endpoint. ```php ``` -------------------------------- ### Get Racecards - Python3 Request Source: https://api.theracingapi.com/documentation/index Example of how to make a request to the /v1/racecards/basic endpoint using Python3. This shows how to construct the request with authentication headers and handle the JSON response. ```python import requests username = "USERNAME" password = "PASSWORD" url = "https://api.theracingapi.com/v1/racecards/basic" response = requests.get(url, auth=(username, password)) if response.status_code == 200: data = response.json() print(data) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Get Racecards - PHP Request Source: https://api.theracingapi.com/documentation/index Example of how to make a request to the /v1/racecards/basic endpoint using PHP. This illustrates setting up basic authentication and processing the JSON response. ```php ``` -------------------------------- ### Trainer Distance Analysis Example (cURL) Source: https://api.theracingapi.com/documentation/index Example of how to request trainer statistics by race distance using cURL. Requires basic authentication with username and password. ```bash curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/trainers/{trainer_id}/analysis/distances ``` -------------------------------- ### Get Racecards - Curl Request Source: https://api.theracingapi.com/documentation/index Example of how to make a request to the /v1/racecards/basic endpoint using curl. This demonstrates basic authentication with a username and password. ```bash curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/racecards/basic ``` -------------------------------- ### Python Request for Damsire Results Source: https://api.theracingapi.com/documentation/index Example Python script using the 'requests' library to fetch damsire results. This code demonstrates how to make a GET request to the API endpoint and handle the JSON response. Ensure you have the 'requests' library installed. ```python import requests api_url = "https://api.theracingapi.com/v1/damsires/{damsire_id}/results" username = "YOUR_USERNAME" password = "YOUR_PASSWORD" response = requests.get(api_url, auth=(username, password)) if response.status_code == 200: data = response.json() print(data) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Get Jockey Results - PHP Example Source: https://api.theracingapi.com/documentation/index PHP script to fetch a jockey's race results using cURL. This example shows how to set up the cURL request with basic authentication and retrieve the JSON response. Remember to replace USERNAME, PASSWORD, and {jockey_id}. ```php ``` -------------------------------- ### Get North American Meet Results - Python3 Request Example Source: https://api.theracingapi.com/documentation/index This Python 3 example shows how to retrieve meet results from The Racing API. It utilizes the `requests` library for making HTTP requests and includes basic authentication. The `meet_id` is a path parameter, and the response will be in JSON format. ```python import requests username = "USERNAME" password = "PASSWORD" meet_id = "{meet_id}" url = f"https://api.theracingapi.com/v1/north-america/meets/{meet_id}/results" response = requests.get(url, auth=(username, password)) if response.status_code == 200: print(response.json()) elif response.status_code == 404: print("Meet not found.") else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Python3 Request Example for Racecard Summaries Source: https://api.theracingapi.com/documentation/index This snippet shows how to fetch racecard summaries using Python 3. It utilizes the 'requests' library for making HTTP GET requests to the API. Authentication is handled by passing username and password in the 'auth' parameter. The response is expected in JSON format. ```python import requests username = "USERNAME" password = "PASSWORD" url = "https://api.theracingapi.com/v1/racecards/summaries" response = requests.get(url, auth=(username, password)) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Get Jockey Results - Python Example Source: https://api.theracingapi.com/documentation/index Python 3 script to retrieve a jockey's race results using the requests library. It demonstrates how to make the API call with basic authentication and parse the JSON response. Replace USERNAME, PASSWORD, and {jockey_id} with actual values. ```python import requests username = "USERNAME" password = "PASSWORD" jockey_id = "{jockey_id}" url = f"https://api.theracingapi.com/v1/jockeys/{jockey_id}/results" try: response = requests.get(url, auth=(username, password)) response.raise_for_status() # Raise an exception for bad status codes data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Error: {e}") ``` -------------------------------- ### Jockey Trainer Analysis Request Example (curl) Source: https://api.theracingapi.com/documentation/index Example of how to request jockey statistics by trainer using curl. This endpoint requires authentication and accepts various query parameters to filter the results. ```bash curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/jockeys/{jockey_id}/analysis/trainers ``` -------------------------------- ### Fetch Trainer Results using PHP Source: https://api.theracingapi.com/documentation/index This snippet illustrates how to fetch trainer results using PHP. It sets up the necessary authentication credentials and the API endpoint URL. The response is then processed, and the JSON data is outputted. ```php ``` -------------------------------- ### Python Request Example for Searching Horses Source: https://api.theracingapi.com/documentation/index Demonstrates how to search for horses using Python's requests library. This includes setting up basic authentication and the request URL. ```python import requests username = "USERNAME" password = "PASSWORD" url = "https://api.theracingapi.com/v1/horses/search" response = requests.get(url, auth=(username, password)) print(response.json()) ``` -------------------------------- ### Get North American Meet Results - PHP Request Example Source: https://api.theracingapi.com/documentation/index This PHP snippet illustrates how to make a request to get North American meet results. It uses cURL to send an authenticated GET request to the API endpoint, requiring the meet ID. The response is expected to be JSON, which can then be processed. ```php ``` -------------------------------- ### Get Courses List - Python Source: https://api.theracingapi.com/documentation/index Retrieves a list of all available courses, including their IDs and regions using Python. This endpoint is available for the Free plan with a rate limit of 2 requests per second. Authentication is done via HTTP Basic. ```python import requests url = "https://api.theracingapi.com/v1/courses" headers = { "Authorization": "Basic USERNAME:PASSWORD" } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Search Owners Request Sample (Python3) Source: https://api.theracingapi.com/documentation/index This snippet shows how to search for owners by name using Python3. It requires basic authentication and the 'name' query parameter. ```python import requests url = "https://api.theracingapi.com/v1/owners/search" auth = ("USERNAME", "PASSWORD") params = { "name": "ExampleName" } response = requests.get(url, auth=auth, params=params) print(response.json()) ``` -------------------------------- ### Search Owners Request Sample (PHP) Source: https://api.theracingapi.com/documentation/index This snippet shows how to search for owners by name using PHP. It requires basic authentication and the 'name' query parameter. ```php 'ExampleName']); curl_setopt($ch, CURLOPT_URL, "https://api.theracingapi.com/v1/owners/search?" . $query_params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERPWD, "USERNAME:PASSWORD"); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close($ch); $data = json_decode($response, true); print_r($data); ?> ``` -------------------------------- ### Curl Request for Horse Results Source: https://api.theracingapi.com/documentation/index Example of how to make a curl request to the /v1/horses/{horse_id}/results endpoint to get historical results for a specific horse. Basic authentication is required. ```shell curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/horses/{horse_id}/results ``` -------------------------------- ### PHP Request Example for Racecard Summaries Source: https://api.theracingapi.com/documentation/index This snippet illustrates how to retrieve racecard summaries using PHP. It employs cURL to send an HTTP GET request to the API endpoint. Basic authentication is configured using CURLOPT_USERPWD. The response is then processed as JSON. ```php ``` -------------------------------- ### Get Jockey Analysis Trainers Request Sample (PHP) Source: https://api.theracingapi.com/documentation/index This snippet demonstrates how to make a request to the jockey analysis trainers endpoint using PHP. It requires basic authentication with a username and password. ```php ``` -------------------------------- ### Get Dam Progeny Class Analysis Request (cURL) Source: https://api.theracingapi.com/documentation/index Example cURL command to retrieve dam progeny statistics by race class. Requires basic authentication with USERNAME and PASSWORD and a valid dam_id. The endpoint supports various query parameters for filtering results. ```shell curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/dams/{dam_id}/analysis/classes ``` -------------------------------- ### Response Sample for /v1/owners/{owner_id}/analysis/courses Source: https://api.theracingapi.com/documentation/index This JSON structure represents a successful response for owner course analysis. It includes race details and runner statistics for each course analyzed. Note that some fields like 'surface', 'jumps', 'winning_time_detail', 'comments', 'non_runners', and various 'tote' fields are empty in this specific sample. ```json { "results": [ { "race_id": "string", "date": "string", "region": "string", "course": "string", "course_id": "string", "off": "string", "off_dt": "string", "race_name": "string", "type": "string", "class": "string", "pattern": "string", "rating_band": "string", "age_band": "string", "sex_rest": "string", "dist": "string", "dist_y": "string", "dist_m": "string", "dist_f": "string", "going": "string", "surface": "", "jumps": "", "runners": [ { "horse_id": "string", "horse": "string", "sp": "string", "sp_dec": "string", "number": "string", "position": "string", "draw": "string", "btn": "string", "ovr_btn": "string", "age": "string", "sex": "string", "weight": "string", "weight_lbs": "string", "headgear": "string", "time": "string", "or": "string", "rpr": "string", "tsr": "string", "prize": "string", "jockey": "string", "jockey_claim_lbs": "0", "jockey_id": "string", "trainer": "string", "trainer_id": "string", "owner": "string", "owner_id": "string", "sire": "string", "sire_id": "string", "dam": "string", "dam_id": "string", "damsire": "string", "damsire_id": "string", "comment": "string", "silk_url": "" } ], "winning_time_detail": "", "comments": "", "non_runners": "", "tote_win": "", "tote_pl": "", "tote_ex": "", "tote_csf": "", "tote_tricast": "", "tote_trifecta": "" } ], "total": 0, "limit": 0, "skip": 0, "query": [ [ null ] ] } ``` -------------------------------- ### Get Courses List - PHP Source: https://api.theracingapi.com/documentation/index Retrieves a list of all available courses, including their IDs and regions using PHP. This endpoint is available for the Free plan with a rate limit of 2 requests per second. Authentication is done via HTTP Basic. ```php ``` -------------------------------- ### Owner Course Analysis Endpoint - cURL Request Example Source: https://api.theracingapi.com/documentation/index This cURL command demonstrates how to make a request to the Owner Course Analysis endpoint. Replace USERNAME and PASSWORD with your actual API credentials. The endpoint requires the owner_id as a path parameter. ```curl curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/owners/{owner_id}/analysis/courses ``` -------------------------------- ### Curl Request Example for Racecard Summaries Source: https://api.theracingapi.com/documentation/index This snippet demonstrates how to make a request to the racecard summaries endpoint using curl. It requires basic authentication with a username and password. The endpoint fetches racecard summaries based on provided query parameters. ```curl curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/racecards/summaries ``` -------------------------------- ### Get North American Meet Results - cURL Request Example Source: https://api.theracingapi.com/documentation/index This snippet demonstrates how to fetch meet results for a North American race using cURL. It requires basic authentication with a username and password and specifies the meet ID in the URL path. Ensure you replace USERNAME, PASSWORD, and {meet_id} with your actual credentials and the relevant meet identifier. ```bash curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/north-america/meets/{meet_id}/results ``` -------------------------------- ### Get Jockey Distance Analysis (PHP) Source: https://api.theracingapi.com/documentation/index This snippet shows how to get jockey distance analysis data using PHP. It utilizes cURL to perform an authenticated GET request to the specified API endpoint. ```php ``` -------------------------------- ### Get Jockey Analysis Trainers Request Sample (Python3) Source: https://api.theracingapi.com/documentation/index This snippet demonstrates how to make a request to the jockey analysis trainers endpoint using Python3. It requires basic authentication with a username and password. ```python import requests url = "https://api.theracingapi.com/v1/jockeys/{jockey_id}/analysis/trainers" auth = ("USERNAME", "PASSWORD") response = requests.get(url, auth=auth) print(response.json()) ``` -------------------------------- ### GET /v1/owners/{owner_id}/results Source: https://api.theracingapi.com/documentation/index Get full historical results for a specific owner, with options to filter by date, region, course, and more. ```APIDOC ## GET /v1/owners/{owner_id}/results ### Description Get full historical results for a specific owner, with options to filter by date, region, course, and more. ### Method GET ### Endpoint https://api.theracingapi.com/v1/owners/{owner_id}/results ### Parameters #### Path Parameters - **owner_id** (string) - Required - The ID of the owner. #### Query Parameters - **start_date** (string) - Optional - Query from date with format YYYY-MM-DD, e.g. `2020-01-01`. - **end_date** (string) - Optional - Query to date with format YYYY-MM-DD, e.g. `2020-01-01`. - **region** (array of strings) - Optional - Query by region codes. - **course** (array of strings) - Optional - Query by course ids. - **type** (array of strings) - Optional - Query by race type. Options: `chase`, `flat`, `hurdle`, `nh_flat`. - **going** (array of strings) - Optional - Query by going. Options: `fast`, `firm`, `good`, `good_to_firm`, `good_to_soft`, `good_to_yielding`, `hard`, `heavy`, `holding`, `muddy`, `sloppy`, `slow`, `soft`, `soft_to_heavy`, `standard`, `standard_to_fast`, `standard_to_slow`, `very_soft`, `yielding`, `yielding_to_soft`. - **race_class** (array of strings) - Optional - Query by class. Options: `class_1`, `class_2`, `class_3`, `class_4`, `class_5`, `class_6`, `class_7`. - **min_distance_y** (integer) - Optional - Query by minimum race distance (yards). - **max_distance_y** (integer) - Optional - Query by maximum race distance (yards). - **age_band** (array of strings) - Optional - Query by age band. Options: `10yo+`, `2-3yo`, `2yo`, `2yo+`, `3-4yo`, `3-5yo`, `3-6yo`, `3yo`, `3yo+`, `4-5yo`, `4-6yo`, `4-7yo`, `4-8yo`, `4yo`, `4yo+`, `5-6yo`, `5-7yo`, `5-8yo`, `5yo`, `5yo+`, `6-7yo`, `6yo`, `6yo+`, `7yo+`, `8yo+`, `9yo+`. - **sex_restriction** (array of strings) - Optional - Query by sex restriction. Options: `c&f`, `c&g`, `f`, `f&m`, `m`, `m&g`. - **limit** (integer) - Optional - Maximum number of results to return (1-50). Default: 25. - **skip** (integer) - Optional - Number of results to skip (<= 20000). Default: 0. ### Request Example ```json { "example": "curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/owners/{owner_id}/results?start_date=2020-01-01&limit=10" } ``` ### Response #### Success Response (200) - The response structure for this endpoint is not fully detailed in the provided text, but it is expected to return historical results for the owner. #### Response Example ```json { "example": "// Response structure to be detailed" } ``` ``` -------------------------------- ### GET /v1/odds/{race_id}/{horse_id} Source: https://api.theracingapi.com/documentation/index Get detailed pre-race runner odds data, including price movements, for UK and Irish racing. ```APIDOC ## GET /v1/odds/{race_id}/{horse_id} ### Description Get detailed pre-race runner odds data, including price movements, for UK and Irish racing. ### Method GET ### Endpoint https://api.theracingapi.com/v1/odds/{race_id}/{horse_id} ### Parameters #### Path Parameters - **race_id** (string) - Required - Race ID. - **horse_id** (string) - Required - Horse ID. ### Request Example ```json { "example": "curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/odds/{race_id}/{horse_id}" } ``` ### Response #### Success Response (200) - **race_id** (string) - The ID of the race. - **horse_id** (string) - The ID of the horse. - **horse** (string) - The name of the horse. - **odds** (array) - A list of odds information for the horse. #### Response Example ```json { "example": { "race_id": "string", "horse_id": "string", "horse": "string", "odds": [] } } ``` ``` -------------------------------- ### Horse Distance Time Analysis Request Example Source: https://api.theracingapi.com/documentation/index Demonstrates how to call the Horse Distance Time Analysis endpoint using cURL. Requires authentication with username and password, and specifies the horse_id in the URL. ```shell curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/horses/{horse_id}/analysis/distance-times ``` -------------------------------- ### GET /v1/horses/{horse_id}/standard Source: https://api.theracingapi.com/documentation/index Retrieves a basic horse profile. This endpoint can also be used to get profiles for a sire, dam, or damsire by prefixing their IDs with 'hrs_'. ```APIDOC ## GET /v1/horses/{horse_id}/standard ### Description Get a basic horse profile. You may also get profiles for a sire/dam/damsire using this endpoint by replacing their id prefix with 'hrs_'. ### Method GET ### Endpoint /v1/horses/{horse_id}/standard ### Parameters #### Path Parameters - **horse_id** (string) - Required - Horse Id ### Request Example ```curl curl -u USERNAME:PASSWORD https://api.theracingapi.com/v1/horses/{horse_id}/standard ``` ### Response #### Success Response (200) - **id** (string) - **horse** (string) - **sire** (string) - **sire_id** (string) - **dam** (string) - **dam_id** (string) - **damsire** (string) - **damsire_id** (string) - **total_runs** (integer) - **distances** (array) - **query** (array) #### Response Example ```json { "id": "string", "horse": "string", "sire": "string", "sire_id": "string", "dam": "string", "dam_id": "string", "damsire": "string", "damsire_id": "string", "total_runs": 0, "distances": [ { "dist": "string", "dist_y": "string", "dist_m": "string", "dist_f": "string", "times": [ { "date": "string", "region": "string", "course": "string", "time": "string", "going": "string", "position": "string" } ], "runs": 0, "1st": 0, "2nd": 0, "3rd": 0, "4th": 0, "a/e": 0, "win_%": 0, "1_pl": 0 } ], "query": [ [ null ] ] } ``` ``` -------------------------------- ### GET /v1/damsires/{damsire_id}/analysis/distances Source: https://api.theracingapi.com/documentation/index Get damsire grandoffspring statistics by race distance. This endpoint provides insights into how offspring of a specific damsire perform across different race distances. ```APIDOC ## GET /v1/damsires/{damsire_id}/analysis/distances ### Description Get damsire grandoffspring statistics by race distance. This endpoint provides insights into how offspring of a specific damsire perform across different race distances. ### Method GET ### Endpoint /v1/damsires/{damsire_id}/analysis/distances ### Parameters #### Path Parameters - **damsire_id** (string) - Required - The ID of the damsire. #### Query Parameters - **start_date** (string) - Optional - Query from date with format YYYY-MM-DD, e.g. `2020-01-01` - **end_date** (string) - Optional - Query to date with format YYYY-MM-DD, e.g. `2020-01-01` - **region** (Array of strings) - Optional - Query by region codes. Get the full list here. Note: If the course query parameter is specified, this will be ignored. - **course** (Array of strings) - Optional - Query by course ids. Get the full list here. - **type** (Array of strings) - Optional - Query by race type. Options: `chase`, `flat`, `hurdle`, `nh_flat` - **going** (Array of strings) - Optional - Query by going. Options: `fast`, `firm`, `good`, `good_to_firm`, `good_to_soft`, `good_to_yielding`, `hard`, `heavy`, `holding`, `muddy`, `sloppy`, `slow`, `soft`, `soft_to_heavy`, `standard`, `standard_to_fast`, `standard_to_slow`, `very_soft`, `yielding`, `yielding_to_soft` - **race_class** (Array of strings) - Optional - Query by class. Options: `class_1`, `class_2`, `class_3`, `class_4`, `class_5`, `class_6`, `class_7` - **min_distance_y** (integer) - Optional - Query by minimum race distance (yards) - **max_distance_y** (integer) - Optional - Query by maximum race distance (yards) - **age_band** (Array of strings) - Optional - Query by age band. Options: `10yo+`, `2-3yo`, `2yo`, `2yo+`, `3-4yo`, `3-5yo`, `3-6yo`, `3yo`, `3yo+`, `4-5yo`, `4-6yo`, `4-7yo`, `4-8yo`, `4yo`, `4yo+`, `5-6yo`, `5-7yo`, `5-8yo`, `5yo`, `5yo+`, `6-7yo`, `6yo`, `6yo+`, `7yo+`, `8yo+`, `9yo+` - **sex_restriction** (Array of strings) - Optional - Query by sex restriction. Options: `c&f`, `c&g`, `f`, `f&m`, `m`, `m&g` ### Request Example ```json { "damsire_id": "example_damsire_id", "min_distance_y": 1200, "max_distance_y": 2000 } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the damsire. - **damsire** (string) - The name of the damsire. - **total_runners** (integer) - The total number of runners for the damsire. - **distances** (Array of objects) - Statistics for each race distance. - **distance** (integer) - The race distance in yards. - **runners** (integer) - The number of runners at that distance. - **1st** (integer) - Number of 1st place finishes. - **2nd** (integer) - Number of 2nd place finishes. - **3rd** (integer) - Number of 3rd place finishes. - **4th** (integer) - Number of 4th place finishes. - **a/e** (float) - The "age/experience" statistic. - **win_%** (float) - The win percentage. - **1_pl** (integer) - Number of 1st place plus finishes. - **query** (Array of Arrays) - The query parameters used for the request. #### Response Example ```json { "id": "654", "damsire": "Damsire Name", "total_runners": 150, "distances": [ { "distance": 1600, "runners": 75, "1st": 15, "2nd": 12, "3rd": 10, "4th": 11, "a/e": 1.1, "win_%": 20.0, "1_pl": 38 } ], "query": [ ["min_distance_y", "1200"] ] } ``` ```