Errors

TransitKit returns proper HTTP status codes and a consistent JSON error shape for all error responses. No more digging through systemMessages in 200 OK responses.


Error Shape

All errors return this consistent JSON structure:

Error Response
{
  "error": {
    "code": "INVALID_STOP",
    "message": "No stop found with ID '99999'. Use /v1/stops/search to find valid stop IDs.",
    "docs": "https://transitkit.dev/docs/errors#INVALID_STOP"
  }
}

Error Codes

HTTP StatusError CodeDescription
401UNAUTHORIZEDMissing or invalid API key
400INVALID_STOPStop ID not found in TfNSW system
400MISSING_PARAMRequired parameter not provided
429RATE_LIMITEDDaily request limit exceeded
503UPSTREAM_ERRORTfNSW API unavailable

Compared to TfNSW

The raw TfNSW API returns HTTP 200 for nearly all responses, including errors. Error information is buried in a systemMessages array within the response body. Your HTTP client treats these as successful responses, making error handling unreliable.

TransitKit translates these into proper HTTP status codes so you can use standard error handling patterns in any language.