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

StatuscodeWhen
400invalid_requestA parameter is missing, malformed or out of range. detail names it.
400invalid_cursorThe paging cursor is unknown, expired, or was made for other filters. See Paging.
401api_key_missingNo X-Api-Key header.
401api_key_invalidThe key is unknown or revoked.
401member_token_requiredA member operation with no Authorization: Bearer token. See Authentication.
401member_token_invalidThe member token is malformed, expired, revoked or not ours. Log in again.
403origin_not_allowedA publishable key from an origin that is not on its list.
403server_key_in_browserA server key sent with an Origin header.
403club_mismatchThe club in the path is not the key's club.
403not_a_memberA valid member login, but not a member of this club. Logging in again will not help.
403feature_not_in_planThe operation's feature group is off for the club's plan.
404club_not_foundThe key's club no longer exists, or it is a draft (unpublished) club and no member token of that club was sent. See Authentication.
404fixture_not_foundNo such fixture, or it is not published, or it is another club's. The API does not say which.
404teamsheet_not_foundThe fixture's teamsheet is not published (or there is none). See Selection.
404league_not_foundNo league with that id.
404news_not_foundNo 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.
404trophy_not_foundNo such trophy in this club. See News, honours and trophies.
409availability_not_enabled, fixture_started, teamsheet_published, non_playing_member, not_eligible, invitation_only, member_awayThe 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.
404route_not_foundNo such path or method. Includes operations that are not available yet.
429rate_limitedOver the key's rate, or blocked. See Retry-After and Rate limits.
502upstream_errorThe lovebowls service behind the API failed. Safe to retry.
500internal_errorA 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

StatusRetry?
429Yes, after waiting Retry-After seconds.
502Yes, with a short back-off: wait a second, then two, then four, and stop after three or four tries.
500Once, if at all. Then report it.
400, 401, 403, 404, 409No. 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:

statuscodeMeaning
0network_errorThe request never got an answer (offline, DNS, blocked by CORS). Retry later.
(as received)invalid_responseThe body was not JSON, was an error body that is not a problem document, or a page repeated its cursor.
0member_token_requiredA member method with no usable token (never logged in, or the session ended). No request was made.
0login_failed, state_mismatchThe 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.