Searching declared horses
/v1/horses/searchAll live plansCase-insensitive substring search over declared runners in one daily feed.
q is required, between 1 and 100 characters, and must be URL-encoded. Matching ignores case and finds substrings, so q=star matches any declared horse containing those letters. The search covers the selected daily feed only: it is not a global or historical horse database, so a horse that is not declared that day will not appear. No match returns an empty list, not 404.
// Server route: GET /api/horse-search?q=...
export async function searchHorses(q, day = {}) {
const term = String(q || "").trim().slice(0, 100);
if (!term) return [];
const url = new URL("/v1/horses/search", "https://racingapi.net");
url.searchParams.set("region", "uk");
url.searchParams.set("q", term); // URL handles encoding
url.searchParams.set("limit", "20");
if (day.date) url.searchParams.set("date", day.date);
if (day.date && day.tomorrow) throw new Error("Choose date OR tomorrow");
if (day.tomorrow) url.searchParams.set("tomorrow", "true");
const res = await fetch(url, { headers: { "X-API-Key": process.env.RACINGAPI_KEY } });
const body = await res.json();
if (!res.ok) throw new Error(body.code);
return body.data.map(h => ({ id: h.id, name: h.name }));
}Fetching a declared horse profile
/v1/horses/{id}All live plansThe horse as declared in the selected feed, with weight, connections, form rows and prices.
Replace {id} with a horse ID from a racecard runner or a search hit. The profile contains name, age, gender, weight, weightLbs, rating, stall, distance, jockey and trainer objects, supplied form rows and odds rows. These come from that day's declarations. It is a runner profile, not a career archive.
curl --fail-with-body \
"https://racingapi.net/v1/horses/$HORSE_ID?region=uk&date=$RACE_DATE" \
-H "X-API-Key: $RACINGAPI_KEY"Set RACE_DATE to the same YYYY-MM-DD used for discovery; the PHP example defaults to today if it is unset. Run its printf output in a terminal, or HTML-escape it before displaying it on a page. weight preserves source text: do not assume a unit or convert an unexplained code. weightLbs is the supplied pounds field, not a calculation. A blank rating or stall means not supplied. A horse absent from the selected feed returns 404.
Where the profile leads
- 1Horse id. From search or a racecard runner.
- 2Form statistics. /v1/horses/{id}/form with raceId for the summary rows.
- 3Jockey and trainer ids. Open /v1/jockeys/{id} or /v1/trainers/{id} for that day's bookings.
- 4Silk image. /v1/silks/{id} with raceId, proxied by your server.
Continue with Horse form statistics and Jockeys and trainers. Schemas are in the API reference.
Reference material
Exact schemas: API reference. First call: Quickstart. Copy-ready helpers: Code examples. Plans: Pricing.