Skip to content

TutorialsLesson 7 of 15Racing data7 min read

Jockeys and trainers: daily bookings and connections

Use /v1/jockeys/{id} and /v1/trainers/{id} to list a jockey's rides or a trainer's runners for one day, with horse-specific connection statistics.

  • List a jockey's rides for a day
  • List a trainer's runners for a day
  • Avoid double-counting connection statistics

A jockey's bookings

GET/v1/jockeys/{id}All live plans

A jockey's bookings in the selected daily feed, with horse-specific connection rows.

Take {id} from runner.jockey.id on a racecard. The response has id, name, scope and bookings[]. Each booking has horseId, horseName, raceId, name and connections[], which are the form rows in the connections section that match this jockey for that horse.

async function connection(kind /* "jockeys" | "trainers" */, id, date) {
  const url = new URL("/v1/" + kind + "/" + encodeURIComponent(id), "https://racingapi.net");
  url.searchParams.set("region", "uk");
  if (date) url.searchParams.set("date", date);
  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 + " " + body.requestId);
  return body.data;
}

const jockey = await connection("jockeys", process.env.JOCKEY_ID);
for (const b of jockey.bookings) console.log(jockey.name, "rides", b.horseName, "in race", b.raceId);

A trainer's runners

GET/v1/trainers/{id}All live plans

A trainer's declared runners in the selected daily feed, with horse-specific connection rows.

Take {id} from runner.trainer.id. The shape matches the jockey endpoint, so one helper serves both. A trainer page that lists 'runners today' is a natural use: group bookings by raceId, then look the race time and course up from your cached racecards rather than calling the race endpoint for each booking.

import os, requests

def trainer(trainer_id, date=None):
    params = {"region": "uk"}
    if date: params["date"] = date
    res = requests.get(f"https://racingapi.net/v1/trainers/{trainer_id}", params=params,
                       headers={"X-API-Key": os.environ["RACINGAPI_KEY"]}, timeout=15)
    if res.status_code == 404:
        return None   # no runners in this feed
    res.raise_for_status()
    return res.json()["data"]

t = trainer(os.environ["TRAINER_ID"])
if t:
    for b in t["bookings"]:
        print(b["raceId"], b["horseName"])

Daily connections, not career statistics

Connection rows describe how this jockey or trainer has done with this particular horse, as supplied. They are horse-specific. Adding them up across a day's bookings would count the same historic runs more than once and produce a number that looks like a career strike rate but is not one. RacingAPI.net does not offer jockey or trainer career-statistics endpoints, so present these rows per horse.

DiagramJoining connections to the card
Joining connections to the card: step 1, Racecard runner; step 2, Connection endpoint; step 3, Join by raceId; step 4, Show per horse.1 YOUR SERVERRacecard runner2 RACINGAPI.NETConnection endpoint3 CACHEJoin by raceId4 VISITORShow per horse
  1. 1Racecard runner. Read runner.jockey.id and runner.trainer.id.
  2. 2Connection endpoint. One request lists every booking for that person on that day.
  3. 3Join by raceId. Look up time and course in your cached racecards.
  4. 4Show per horse. Display each booking's connection rows separately.
Use cached racecards to give each booking its race context.

See the API reference for the booking schema.

Reference material

Exact schemas: API reference. First call: Quickstart. Copy-ready helpers: Code examples. Plans: Pricing.