Developers
Partner API guide
All developer pages · From docs/partner-api.md in the release that is running.
A JSON API for apps outside pub-runners.com: every kind of club record as a REST resource
(runs, results and news can also be written), plus the endpoints the timing app uses. Base URL: https://pub-runners.com/api/v1.
Interactive reference, where you can try requests with your key: https://pub-runners.com/api/docs. The OpenAPI 3.1 spec behind it is at https://pub-runners.com/api/openapi.json, for generating a client.
Practising on staging
Build against https://staging.pub-runners.com first. It runs the same code as the live site (every release goes there first) with a made-up club: fake pubs and routes, about two years of Tuesday results, and a few runners whose next run is their 50th, so milestones show up tonight. None of it is real member data, and it can be reset at any time.
- API base URL:
https://staging.pub-runners.com/api/v1, docs at/api/docson the same host. - Ask the club for a staging key (and, for
/timerwork, a staging host login). Live keys do not work on staging, and staging keys do not work live. POST /timing/runs/tonightopens a run for today whatever the day of the week, so you can practise timing at any time.- An app running on your own machine (for example
http://localhost:5173) should send a staging key as a bearer token. Cookie sign-in only works on pages served from the site itself.
Access
Every request needs a key, sent as a bearer token:
Authorization: Bearer pr_...
Accept: application/json
Ask the club for a key. Each key has abilities; a pattern such as *.read or results.* grants
every match.
| Ability | Lets you |
|---|---|
{resource}.read |
List and fetch that resource, as the public site shows it |
runs.write, results.write, news.write |
Create, update and delete that resource, and see drafts |
runners.private |
See hidden and merged runners, emails and gender, and hidden runners' names in results and awards |
timing.write |
Everything under /timing except finalising |
timing.finalise |
POST /timing/runs/{id}/finalise |
The default key has *.read and timing.write.
- Limit: 120 requests a minute per key.
- Logging: every write is logged against the key that made it.
- Errors: JSON with a
message. Validation errors (422) also carryerrorskeyed by field. A 409 means the request conflicts with existing data, for example deleting a run that still has results.
Signed in on pub-runners.com
Pages served from pub-runners.com, such as the timing app at /timer, can call the /timing
endpoints with the visitor's session instead of a key:
- Hosts and admins can time any open run. Someone who opened a host's one-night timing link can time that run only.
- The browser sends the session cookie itself. On
POST, send theX-XSRF-TOKENheader with the value of theXSRF-TOKENcookie (URL-decoded).GET /sanctum/csrf-cookierefreshes it. - A request with a key never uses the session, so the "try it" button in the reference still works.
Signed-in callers are the club's own timing. They see every runner, hidden ones too, and all of the club's events for a run, and they are never refused with 409 because a partner is timing.
Resources
| Resource | Readers see | Filters | Writable |
|---|---|---|---|
locations |
all | active |
no |
seasons |
all | location_id |
no |
runs |
published runs | from, to, season_id, location_id, status |
yes |
results |
results of published runs | from, to (run date), run_id, runner_id |
yes |
runners |
listed runners | q (name, e.g. adam ca), public_id |
no |
attendance-types |
all | no | |
badges |
all | no | |
awards |
badges awarded to listed runners | from, to, runner_id, badge_id |
no |
news |
published posts | from, to |
yes |
The read-only resources are managed in the club admin; writing to them returns 405. With
runs.write, results.write or news.write, a key also sees drafts: unpublished runs and
their results, and unpublished or scheduled news. Dates are YYYY-MM-DD, and from/to are inclusive.
Each location has route_image_url (the route map), route_card_url (a 1200 × 630 card of the
route, as used for link previews) and route_gpx_url (a GPX download of the route), or null
where the club has not uploaded one. All are public links on pub-runners.com and need no key.
GET /{resource}?per_page=50&page=1 list (per_page up to 200)
GET /{resource}/{id} one record
POST /{resource} create, 201 (runs, results, news)
PATCH /{resource}/{id} update the fields you send
DELETE /{resource}/{id} delete, 204
Lists use Laravel's paginator format: the records are in data, alongside current_page,
per_page, total, last_page, next_page_url and prev_page_url. Single records come back
as {"data": {...}}.
Results from the last 8 weeks, for example:
GET /results?from=2026-09-15&per_page=200
{
"current_page": 1,
"data": [
{
"id": 4021, "run_id": 669, "date": "2026-11-03",
"runner_id": 128, "runner_name": "Daniel Fearnley", "placeholder_label": null,
"position": 1, "elapsed_seconds": 1238, "attendance_type": null,
"source": "import", "note": null,
"is_first_run": false, "is_pb_all_time": false, "is_pb_season": true, "is_pb_location": false
}
],
"next_page_url": "https://pub-runners.com/api/v1/results?from=2026-09-15&per_page=200&page=2",
"total": 812
}
Fields you can write
Fields left out of a create take their defaults. Fields not listed here are read-only. New runners come from timing check-ins (see below); duplicates are merged in the club admin.
| Resource | Writable fields | Notes |
|---|---|---|
runs |
date (one run per date), season_id, status (scheduled, live, finalised, published), notes |
New runs start scheduled. Setting published makes it public. Cannot delete while it has results. |
results |
run_id (on create only), runner_id or placeholder_label, elapsed_seconds (60 to 14400), attendance_type (a slug), note |
One result per runner per run. Saved as manual, so finalising timing again leaves it alone. Positions, PBs and badges recalculate shortly after. |
news |
title, slug, body (HTML, sanitised), published_at (null for a draft), author_name, run_id |
Timing a run
POST /timing/runs/tonightopens tonight's run (or returns it if it is already open):{"id": 670, "date": "2026-11-10", "status": "scheduled", "season": "...", "location": "Badger"}.GET /timing/runslists runs open for timing (yesterday to tomorrow, not yet finalised).GET /timing/runs/{id}/rosterlists everyone you can check in, people seen in the last 8 weeks first, withpredicted(average of their last four timed runs, in seconds) for sorting:{"runners": [{"id": 4, "name": "Adam Cason", "public_id": 2115, "predicted": 2178, "last_seen": "2026-10-13", "recent": true}], "attendance_types": [...]}.- Send what happens as events, as often as you like, with
POST /timing/runs/{id}/events. - Poll
GET /timing/runs/{id}/stateto show the run as it stands (see below). - A club host checks the results and publishes them. With
timing.finaliseyou can build the draft results yourself; publishing is always done by a host.
One app times a run. If the club's own timing app has already sent anything for a run, your events for it are refused with 409, and the other way round is not blocked, so a host can step in.
POST /timing/runs/{id}/events
{
"events": [
{
"uuid": "1b4e28ba-2fa1-4d2e-883f-0016d3cca427",
"type": "finish",
"payload": {"runners": [{"runner_id": 4}]},
"client_at": "2026-11-10T07:12:03.250Z",
"device_id": "phone-1"
}
]
}
- Up to 500 events per request.
uuid: generate it on the device. Resending the same event is safe: it is stored once.client_at: when it happened, from the device clock, ISO 8601. Times are worked out as finish minus start on that clock, so keep one device as the stopwatch.device_id: any label up to 64 characters.
Response: {"accepted": [uuid, ...], "rejected": [uuid, ...], "server_time": "..."}. A UUID is
rejected only if it was already used, by another app or for another run; make a new one.
If any event in a request is invalid, none are stored and you get a 422 saying which.
Event types
A runner is {"runner_id": 4} for someone on the list, or {"new": "k1"} for someone first
checked in tonight with that key.
| Type | Payload | Meaning |
|---|---|---|
checkin |
{"runner_id": 4} or {"new_runner": {"key": "k1", "first_name": "Nina", "last_name": "New", "email": "nina@example.com"}}, optionally with "estimate_seconds": 1800 |
They are here. New runners are created when the run is finalised; email is optional and only hosts and admins see it. estimate_seconds is their guess when they have no history. |
gun |
{} |
The start. If there is more than one, the last counts. |
start |
{"runner": runner} |
A late starter setting off. Their time counts from here instead of the gun. |
finish |
{"runners": [runner, ...]} |
Someone crossed the line. Up to 10 together; an empty list is "someone, name later". |
assign |
{"finish": uuid, "runner": runner} |
Names an empty finish. |
self_reported |
{"runner": runner, "seconds": 1490} |
A time they give you, 300 to 7200 seconds. |
attendance |
{"runner": runner, "type": "walked"} |
Came but was not timed; type from attendance_types. |
back |
{"runner": runner} |
A walker is back. Shown in the state only. |
end |
{} |
The timer has ended the run. Shown in the state only; void it to carry on. |
void |
{"target": uuid} |
Undoes one of your earlier events. |
A runner's latest finish, self-reported time or attendance is the one that counts. Anything not in the table above is dropped from the payload.
GET /timing/runs/{id}/state
The run as it stands, built from every event in it: yours, the club's and participants'. Poll it
every few seconds with the last ETag in If-None-Match; while nothing has changed the answer
is 304 with no body.
{
"run": {"id": 670, "date": "2026-11-10", "status": "live"},
"gun": {"uuid": "...", "at": "2026-11-10T07:45:00.000Z"},
"end": null,
"people": [
{
"ref": "id:4", "runner_id": 4, "name": "Adam Cason",
"checked_in_at": "2026-11-10T07:40:00.000Z", "late": false,
"started_at": null, "finished_at": "2026-11-10T08:11:23.250Z", "seconds": 1583,
"source": "timer", "attendance": null, "back_at": null,
"predicted": 1610, "estimated": false, "run_number": 50, "milestone": true, "course_best": 1544,
"events": {"checkin": "...", "start": null, "outcome": "...", "back": null}
}
],
"placeholders": [{"uuid": "...", "finished_at": "...", "seconds": 1702}],
"counts": {"checked_in": 31, "finished": 22, "attendance": 6, "placeholders": 1},
"server_time": "2026-11-10T08:12:00.000Z"
}
refisid:4for someone on the roster andnew:k1for someone new tonight; use it to build the runner reference in events.secondsruns from their ownstartif they had one, otherwise from the gun.predictedis the average of their last four timed runs, or their own estimate whenestimatedis true.run_numbermakes tonight their Nth pub run;milestonemarks every 50th.eventsholds the UUIDs behind each row, so the timer canvoidthem.- With a key, hidden runners' names are
null.
GET /timing/join-code and PATCH /timing/join-code
The code participants type to join tonight's run, such as {"code": "1901"}. There is one code
for the club, 1901 to start with, and it carries over from week to week. A host, or a key with
timing.write, changes it with PATCH {"code": "PINTS"}: 3 to 12 letters or numbers, saved in
upper case. The new code applies from the next phone that joins; phones that already joined keep
working. Show it, or a QR code of it, on the timer's phone.
GET /timing/runs/{id}/events?after=0
Your own events for the run, in order, so a second device can catch up. Pass the last id you have
as after to get only newer ones.
POST /timing/runs/{id}/finalise
Needs timing.finalise. Builds draft results from the events. If someone checked in but has no
finish or attendance, you get 422 with their names in unresolved; send {"force": true} to record
them as "ran, no time". Rerunnable until a host publishes the run.
Participants
People can check themselves in on their own phones, with no account or key, using the join code
the timer shows. Base URL: https://pub-runners.com/api/v1/participant.
POST /joinwith{"code": "1901"}returns{"token": "pt_...", "run": {...}}. Keep the token on the phone for the night and send it asAuthorization: Bearer pt_.... It only joins tonight's run (the run dated today, once it is open and until it is finalised). A wrong code, or no run open tonight, is 404, and joining is limited to 10 attempts a minute.GET /roster?q=adam cafinds their name: up to 10 listed runners whose names start with every word, from at least three letters.POST /checkinwith{"runner_id": 4, "kind": "runner"}, or{"new_runner": {"first_name": "Nina", "last_name": "New", "email": "nina@example.com"}, "kind": "walker"}.kindisrunner,walkerorpub; a runner with no history may addestimate_seconds. 409 if this phone or that name is already checked in.GET /stateshows the start, the end and their own check-in, start, finish and time. Other people appear only as counts.POST /startis for someone who arrived after the start: their time counts from now. It uses the server's clock, so a phone cannot move its own start.DELETE /checkintakes the check-in back ("Not you?") until they have a finish time.
A participant's check-ins are ordinary timing events, so the timer sees them in the state and can void them like any other.