Request and Response
Common types
All dates are expressed as UNIX timestamps, with the exception of timetable times, which are shown in H:MM
format (e.g. 4:32, 15:12. 24:06).
Latitude and longitude will be expressed as floats, with the precision on both the request and response up to six decimal places.
CORS (Cross-domain resource sharing)
The TFE Open Data API supports CORS for communicating from Javascript. Please note that your API token is still considered sensitive and it is your responsibility to protect it.
var xhr = new XMLHttpRequest();
xhr.setRequestHeader("Authorization", "Token YOUR_SERVER_TOKEN");
xhr.open('GET', 'https://tfe-opendata.com/api/v1/timetables/36235979');
HTTP Status Codes
Status code | Description |
---|---|
200 | OK. Everything worked as expected. |
400 | Malformed request. |
401 | Unauthorized the request requires user authentication (not logged in). |
403 | Forbidden. Also used for unauthorized requests or permissions issues. |
404 | Not found. |
406 | Unacceptable content type. Client sent an accepts header for a content type which does not exist on the server. Body includes a list of acceptable content types, such as “Unacceptable content type. Request resource as: application/json |
422 | Invalid request. The request body is parse-able however with invalid content. |
429 | Too Many Requests. Rate limited. |
500 | Internal Server Error. |
Errors
Error responses will have a consistently formed JSON body. The keys may include:
Key | Value |
---|---|
message | Human readable message which corresponds to the client error. |
code | One-word error code |
fields (optional) | A hash of field names that have validations. This has a value of an array with member strings that describe the specific validation error. |
{
"message": "Invalid stop ID",
"code": "invalid",
"fields": {
"stop_id": ["Required"]
}
}
Updated less than a minute ago