Choosing a distance to study
Draw bias only survives at a single distance. The distances array tells you which ones have enough races to be worth the query.
Documentation / Reference & coverage
/v1/courses/{course_id}
Run types, surfaces and distances actually raced there.
Send your key in the X-API-Key header, or as
?key= if your tool cannot set one. A date outside your plan's window returns
403 outside_window naming the window, never an empty array.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| course_id | path | string | yes | Opaque course identifier, as returned by /v1/courses or anywhere a course appears. |
curl https://api.apihorseracing.com/v1/courses/cr_JSRC8Z \ -H "X-API-Key: $AHR_KEY"
$ch = curl_init('https://api.apihorseracing.com/v1/courses/cr_JSRC8Z'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('AHR_KEY')], ]); $data = json_decode(curl_exec($ch), true)['data'];
const res = await fetch( 'https://api.apihorseracing.com/v1/courses/cr_JSRC8Z', { headers: { 'X-API-Key': process.env.AHR_KEY } } ); const { meta, data } = await res.json();
import os, requests r = requests.get( "https://api.apihorseracing.com/v1/courses/cr_JSRC8Z", headers={"X-API-Key": os.environ["AHR_KEY"]}, ).json()
curl https://api.apihorseracing.com/v1/courses/cr_JSRC8Z?key=$AHR_KEY
$url = 'https://api.apihorseracing.com/v1/courses/cr_JSRC8Z' . '?key=$AHR_KEY'; $data = json_decode(file_get_contents($url), true)['data'];
const res = await fetch( 'https://api.apihorseracing.com/v1/courses/cr_JSRC8Z?key=$AHR_KEY' ); const { meta, data } = await res.json();
import os, requests r = requests.get( "https://api.apihorseracing.com/v1/courses/cr_JSRC8Z?key=$AHR_KEY", ).json()
{ "meta": { "request_id": "e06219a616116b7b", "data_as_of": "2026-09-12T05:10:27+00:00", "plan": "analyst", "window": "2017 → upcoming" }, "data": { "course_id": "cr_JSRC8Z", "name": "Fontwell", "shortcode": "FON", "country": "ENG", "region": "GB", "races": 1413, "meetings": 208, "first_meeting": "2017-01-08", "last_meeting": "2026-09-06", "run_types": [ { "run_type": null, "surface": "TURF", "races": 1028, "first": "2018-02-15", "last": "2026-09-06" }, { "run_type": "Hurdle", "surface": "TURF", "races": 205, "first": "2017-01-08", "last": "2020-03-14" }, "… 2 more" ], "distances": [ { "distance": "2m 1f 162y", "races": 354 }, { "distance": "2m 3f 49y", "races": 169 }, "… 19 more" ] } }
A real response from /v1/courses/cr_JSRC8Z,
captured by calling the live API rather than written by hand.
Each field is described once and rendered on every endpoint that returns it, so the wording cannot drift between pages.
| Field | Type | What it is |
|---|---|---|
| course_id | string | Opaque course identifier. |
| name | string | Race title as published, sponsor and all. |
| country | string | Country code as the source publishes it. |
| region | string | Jurisdiction, normalised. Welsh and Scottish racing is GB. |
| run_type | string | Flat, Hurdle, Chase or NH Flat. |
| surface | string | Turf, Dirt, Polytrack and so on. |
| first | integer | Wins. |
| distance | string | Official distance as published, e.g. "3m 3f 119y". |
The code a race was run under lives on the horse profile rather than the race, so it arrives on a later pass. A null run_type means not yet fetched, not unclassified.
| Code | Status | When |
|---|---|---|
| unauthorized | 401 | No key, or one we do not recognise. Check the header name and that the key has not been rotated from your account page. |
| not_found | 404 | The identifier is well formed but nothing has it. Distinct from invalid_id, which means the identifier itself is wrong. |
| invalid_id | 422 | The prefix does not match the kind of thing the path expects, or the identifier is malformed. A horse id passed where a race is wanted lands here rather than returning the wrong race. |
| rate_limited | 429 | Past your per-minute rate. Retry-After is set, and X-RateLimit-Remaining tells you where you stand on every successful response too. |
| server_error | 500 | Ours, not yours. Every response carries a request_id; quote it and we can find the exact request. |
A real request from your browser straight to
api.apihorseracing.com with
your own key. Nothing is proxied and nothing is logged by this page.
Remembered in this browser so you do not paste it on every page. Forget it
One course, with the shape of racing that actually happens there rather than what it is supposed to stage. Run types and surfaces are grouped with their own counts and date spans, and the distances are the ones really raced, most used first.
That distinction matters. A track described as all-weather flat may carry a handful of turf meetings in its history, and a query written against the description would silently include them.
Draw bias only survives at a single distance. The distances array tells you which ones have enough races to be worth the query.
If run_types comes back with a code you did not expect, your filter is about to exclude races you wanted.