Errors
Every error is application/problem+json (RFC 9457):
{
"type": "https://api.lovebowls.co.uk/problems/not-found",
"title": "Not found",
"status": 404,
"code": "fixture_not_found",
"detail": "No published fixture with this id in this club.",
"requestId": "6f1d0c52-6a8e-4f0f-9c2e-0e9b6b6c1a11"
}
Branch on code. It is stable and documented. title and detail are for people and may be reworded.
detail names the parameter at fault on a 400. No key, token or internal address ever appears in an error.
The request id
Every response, successful or not, carries an X-Request-Id header, and an error body repeats it as
requestId. When you ask lovebowls for help, quote it: it finds the exact call.
Codes today
| Status | code | When |
|---|---|---|
| 400 | invalid_request | A parameter is missing, malformed or out of range. detail names it. |
| 400 | invalid_cursor | The paging cursor is unknown, expired, or was made for other filters. See Paging. |
| 401 | api_key_missing | No X-Api-Key header. |
| 401 | api_key_invalid | The key is unknown or revoked. |
| 401 | member_token_required | A member operation with no Authorization: Bearer token. See Authentication. |
| 401 | member_token_invalid | The member token is malformed, expired, revoked or not ours. Log in again. |
| 403 | origin_not_allowed | A publishable key from an origin that is not on its list. |
| 403 | server_key_in_browser | A server key sent with an Origin header. |
| 403 | club_mismatch | The club in the path is not the key's club. |
| 403 | not_a_member | A valid member login, but not a member of this club. Logging in again will not help. |
| 403 | feature_not_in_plan | The operation's feature group is off for the club's plan. |
| 404 | club_not_found | The key's club no longer exists, or it is a draft (unpublished) club and no member token of that club was sent. See Authentication. |
| 404 | fixture_not_found | No such fixture, or it is not published, or it is another club's. The API does not say which. |
| 404 | teamsheet_not_found | The fixture's teamsheet is not published (or there is none). See Selection. |
| 404 | league_not_found | No league with that id. |
| 404 | news_not_found | No such news article for this caller: unknown, outside its show window, another club's, or members-only and the caller is not a member of this club. See News, honours and trophies. |
| 404 | trophy_not_found | No such trophy in this club. See News, honours and trophies. |
| 409 | availability_not_enabled, fixture_started, teamsheet_published, non_playing_member, not_eligible, invitation_only, member_away | The member may not change their availability for this fixture now; the code is the reason, and the rules are applied in that order. See Selection. |
| 404 | route_not_found | No such path or method. Includes operations that are not available yet. |
| 429 | rate_limited | Over the key's rate, or blocked. See Retry-After and Rate limits. |
| 502 | upstream_error | The lovebowls service behind the API failed. Safe to retry. |
| 500 | internal_error | A fault in the gateway. detail is null. Quote the request id. |
More codes will appear as more of the API becomes available: handle an unknown code by looking at
status.
What to retry
| Status | Retry? |
|---|---|
| 429 | Yes, after waiting Retry-After seconds. |
| 502 | Yes, with a short back-off: wait a second, then two, then four, and stop after three or four tries. |
| 500 | Once, if at all. Then report it. |
| 400, 401, 403, 404, 409 | No. The same request will fail the same way. Fix the request, or tell the member why. |
A 404 for a fixture is a normal answer (a fixture can be unpublished), not a fault.
In the SDK
The SDK throws LovebowlsApiError for every failure, with the fields of the problem body and the
response's Retry-After in seconds (null when absent):
import { LovebowlsClient, LovebowlsApiError } from "@lovebowls/api";
const lb = new LovebowlsClient({ apiKey: process.env.LB_KEY });
try {
await lb.getFixture("CLUB_ID", fixtureId);
} catch (error) {
if (!(error instanceof LovebowlsApiError)) throw error;
// error.status, error.code, error.title, error.detail, error.requestId, error.retryAfter
if (error.code === "fixture_not_found") return null;
if (error.status === 429) await sleep((error.retryAfter ?? 5) * 1000);
}
Some codes exist only in the SDK, because no answer came from the API:
status | code | Meaning |
|---|---|---|
| 0 | network_error | The request never got an answer (offline, DNS, blocked by CORS). Retry later. |
| (as received) | invalid_response | The body was not JSON, was an error body that is not a problem document, or a page repeated its cursor. |
| 0 | member_token_required | A member method with no usable token (never logged in, or the session ended). No request was made. |
| 0 | login_failed, state_mismatch | The sign-in did not complete. See Authentication. |
A call with an empty apiKey, or an invalid Date as a filter, throws a TypeError before any request.
With curl
curl -i "https://api.lovebowls.co.uk/v1/clubs/CLUB_ID/fixtures?limit=0" -H "X-Api-Key: $LB_KEY"
-i prints the status line and headers, including X-Request-Id.