Docs for delay api endpoints. Currently very much a work in progress.
Requests to authenticated endpoints must including the X-DELAY-AUTH
header:
Name | Format | Optional | Description |
---|---|---|---|
Auth Token | X-DELAY-AUTH | n | Authentication token for a device. Generated on sign up or sign in |
Please set user agent to the following:
Device Type | User Agent |
---|---|
iOS | Delay-iOS-<$Version> |
Android | Delay-Android-<$Version> |
Web | Delay-Web-<$Version> |
Create a new user. All fields can be left blank and a new anonymous user will be created.
POST /users
Name | Type | Optional | Description |
---|---|---|---|
first_name | string | y | Users first name |
last_name | string | y | Users last name |
string | y | Users email address | |
password | string | y | Users password |
Note: if email is specified, password must also be specified
{
"success": true,
"result": {
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"auth_token": "5f12cd09-0f11-4ed7-867d-3e8884948920",
"created_on": "1501709004"
},
"errors": null,
"meta": {
//meta info
}
}
May return error code 1002.
Returns info for all users auth_token has access to.
GET /users
{
"success": true,
"result": [
{
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"first_name": "Bobby",
"last_name": "Tables",
"email": "[email protected]",
"created_on": "1501709004"
},
{
"id": "aadd50f0-4063-4c3d-a051-15cde26160f5",
"first_name": "Homer",
"last_name": "Simpson",
"email": "[email protected]",
"created_on": "1501709004"
}
],
"errors": null,
"meta": {
// meta info
}
}
Returns info for a particular user.
GET /users/:user_id
{
"success": true,
"result": {
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"first_name": "Bobby",
"last_name": "Tables",
"email": "[email protected]",
"created_on": "1501709004"
},
"errors": null,
"meta": {
// meta info
}
}
Updates given user info. Note that when changing the password new_password
, new_password_repeated
and old_password
are required. Also note that a change in email address wil trigger a new confirmation email to be sent out before the change is applied.
PATCH /users/:user_id
Name | Type | Optional | Description |
---|---|---|---|
first_name | string | y | Users first name |
last_name | string | y | Users last name |
string | y | Users email address | |
new_password | string | y | Users password |
new_password_repeated | string | y | Users new password repeated |
old_password | string | y | Users old password |
{
"success": true,
"result": {
"before": {
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"first_name": "Bobby",
"last_name": "Tables",
"email": "[email protected]",
"created_on": "1501709004"
},
"after": {
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"first_name": "Bobby",
"last_name": "Tables",
"email": "[email protected]",
"created_on": "1501709004"
}
},
"errors": null,
"meta": {
// meta info
}
}
May return error code 1003.
Deletes a given user. This option will revoke all active auth_token
for that user.
DELETE /users/:user_id
{
"success": true,
"result": {
"deleted_on": "1501736051"
},
"errors": null,
"meta": {
// meta info
}
}
Returns an access token for a given email and password.
POST /tokens
Name | Type | Optional | Description |
---|---|---|---|
string | n | Users email address | |
password | string | n | Users password |
{
"success": true,
"result": {
"user_id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"auth_token": "5f12cd09-0f11-4ed7-867d-3e8884948920"
},
"errors": null,
"meta": {
// meta info
}
}
May return error code 1001.
Deletes access token.
DELETE /tokens/:token_id
{
"success": true,
"result": {
"user_id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"deleted_on": "1501736051",
},
"errors": null,
"meta": {
// meta info
}
}
Deletes all access tokens associated with the account of the auth_token
in X-DELAY_AUTH
.
DELETE /tokens
{
"success": true,
"result": {
"id": "7096ca22-435a-470b-9d21-e3ddecbfbc3c",
"deleted_on": "1501736051",
},
"errors": null,
"meta": {
// meta info
}
}
Gets a a list of all services currently running ahead or behind schedule.
GET /delays
{
"success": true,
"result": {
"count": 1,
"date_created": "1501738185",
"valid_until": "1501738215",
"trips": [
{
"id": "894a1261-88b8-49a9-8c07-142fc4299568",
"route_id": "",
"trip_id": "",
"route_long_name": "",
"route_short_name": "",
"next_stop_id": "",
"next_stop_lat": "",
"next_stop_long": "",
"next_stop_arrival_time": "",
"delay": 100,
"vehicle_id": "",
"current_lat": "",
"current_long": ""
}
]
},
"errors": null,
"meta": {
// meta info
}
}
Gets all routes currently in the system. In the context of Delay it is almost always unnecessary to use this endpoint. Instead use search and get individual route.
GET /routes
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"routes": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": ""
}
]
},
"errors": {
"code": 1004,
"desc": "It is almost always unnecessary to call this endpoint."
},
"meta": {
// meta info
}
}
Get route by id.
GET /routes/:route_id
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"routes": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": ""
}
]
},
"errors": null,
"meta": {
// meta info
}
}
Get all trips for a particular route.
GET /routes/:route_id/trips
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"trips": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": "",
"trip_id": "",
"headsign": "",
"trip_begin": "",
"trip_end": "",
"days": [ "Mon", "Tue", "Wed", "Thu", "Fri" ],
"stops": [
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 1,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
},
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 2,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
}
]
}
]
},
]
},
"errors": null,
"meta": {
// meta info
}
}
Search for routes similar to given parameters. params
will be matched against GTFS route_id, route_short_name or route_long_name. Routes similar to multiple parameters in params
will only be returned once. A route_type
can also be specified to limit returned routes to those of a given GTFS routes.route_type
.
Note: search will err on the generous side returning similar not exact matches to params
.
POST /routes/search
Name | Type | Optional | Description |
---|---|---|---|
params | string[] | n | Array of search parameters |
route_type | integer | y | GTFS route type. Learn more here. |
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"routes": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": ""
}
]
},
"errors": null,
"meta": {
// meta info
}
}
Gets all trips currently in the system. In the context of Delay it is almost always unnecessary to use this endpoint. Instead use search and get individual route.
Note: Day in this context is the 3 letter day representation i.e Mon,Tue, Thu etc
GET /trips
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"trips": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": "",
"trip_id": "",
"headsign": "",
"trip_begin": "",
"trip_end": "",
"days": [ "Mon", "Tue", "Wed", "Thu", "Fri" ],
"stops": [
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 1,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
},
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 2,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
}
]
}
]
},
"errors": {
"code": 1004,
"desc": "It is almost always unnecessary to call this endpoint."
},
"meta": {
// meta info
}
}
Gets trip by id.
GET /trips/:trip_id
{
"success": true,
"result": {
"count": 1,
"valid_until": "1502928000",
"trips": [
{
"id": "66407722-89f0-4b71-8797-80971f7b2b22",
"route_id": "",
"route_long_name": "",
"route_short_name": "",
"route_type": "",
"trip_id": "",
"headsign": "",
"trip_begin": "",
"trip_end": "",
"days": [ "Mon", "Tue", "Wed", "Thu", "Fri" ],
"stops": [
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 1,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
},
{
"id": "",
"stop_id": "",
"stop_name": "",
"stop_seq": 2,
"stop_lat": "",
"stop_long": "",
"arrival_time": "",
"departure_time": ""
}
]
}
]
},
"errors": null,
"meta": {
// meta info
}
}
Gets location of trip.
GET /trips/:trip_id/location
{
"success": true,
"result": {
"vehicle_id": "",
"lat": "",
"long": "",
},
"errors": null,
"meta": {
// meta info
}
}
May return error code 1005 if the trip is not active.
Gets all subscriptions auth_token
has access to.
GET /subscriptions
{
"success": true,
"result": {
"count": 2,
"subscriptions": [
{
"id": "",
"route_id": "",
"trip_id": "",
"stop_time": {
"stop_time_id": "",
"stop_id": "",
"stop_name": "",
"stop_code": "",
"arrival_time": "",
"departure_time": ""
},
"days": ["Mon", "Wed"],
"date_created": "",
"archived": false
},
{
"id": "",
"route_id": "",
"trip_id": "",
"stop_time": {
"stop_time_id": "",
"stop_id": "",
"stop_name": "",
"stop_code": "",
"arrival_time": "",
"departure_time": ""
},
"days": ["Mon", "Wed"],
"date_created": "",
"archived": true
},
]
},
"errors": null,
"meta": {
// meta info
}
}
Gets single subscription
GET /subscriptions/:subscription_id
{
"success": true,
"result": {
"id": "",
"route_id": "",
"trip_id": "",
"stop_time": {
"stop_time_id": "",
"stop_id": "",
"stop_name": "",
"stop_code": "",
"arrival_time": "",
"departure_time": ""
},
"days": ["Mon", "Wed"],
"date_created": "",
"archived": false
},
"errors": null,
"meta": {
// meta info
}
}
Create a subscription
POST /subscriptions
Name | Type | Optional | Description |
---|---|---|---|
trip_id | string | n | Delay trip_id |
stop_time_id | string | n | Delay stop_time_id |
days | string[] | n | Array of three letter day codes for which the user wishes to subscribe to the trip for |
notification_ids | uuid[] | y | ID of notification methods. If not present firebase cloud tokens used as default. |
{
"success": true,
"result": {
"id": "",
"route_id": "",
"trip_id": "",
"stop_time": {
"stop_time_id": "",
"stop_id": "",
"stop_name": "",
"stop_code": "",
"arrival_time": "",
"departure_time": ""
},
"days": ["Mon", "Wed"],
"date_created": "",
"archived": false
},
"errors": null,
"meta": {
// meta info
}
}
May return error code 1007.
Modify an existing subscription. In order to stop a user receiving notifications for that subscription it must be archived.
PATCH /subscriptions/:subscription_id
Name | Type | Optional | Description |
---|---|---|---|
trip_id | string | y | Delay trip_id |
stop_time_id | string | y | Delay stop_time_id |
days | string[] | y | Array of three letter day codes for which the user wishes to subscribe to the trip for |
archived | boolean | y | Controls whether or not user gets notification |
{
"success": true,
"result": {
"id": "",
"route_id": "",
"trip_id": "",
"stop_time": {
"stop_time_id": "",
"stop_id": "",
"stop_name": "",
"stop_code": "",
"arrival_time": "",
"departure_time": ""
},
"days": ["Mon", "Wed"],
"date_created": "",
"archived": false
},
"errors": null,
"meta": {
// meta info
}
}
There is no delete method for subscriptions. Subscriptions will be automatically removed when they become invalid.
Create a new notification entry for user. By default when a notifiable event occurs and a subscription has no notification_ids setup delay will send the notification to all firebase cloud tokens setup on the account.
POST /notifications/
Name | Type | Optional | Description |
---|---|---|---|
type | char | n | Type of notification to be register. |
value | string | n | Value for notification. May be email, txt, or firebase cloud token |
name | string | n | User friendly name for notification. For push notifications it is suggested to use the device name |
Character | Name | Description |
---|---|---|
e | Notify via email | |
t | Txt | Notify via txt message (note user must be premium in order to recieve txts) |
p | Push | Notify via firebase cloud messaging push notification |
{
"success": true,
"result": {
"id": "f62a955d-7f06-422d-90fd-af2cd9092d31",
"type": "e",
"value": "[email protected]",
"name": "Work Email",
"date_created": "1503020719"
},
"errors": null,
"meta": {
// meta info
}
}
May return error code 1006.
Returns all notification methods associated with a user account.
GET /notifications/
{
"success": true,
"result": [
{
"id": "f62a955d-7f06-422d-90fd-af2cd9092d31",
"type": "e",
"value": "[email protected]",
"name": "Work Email",
"date_created": "1503020719"
},
{
"id": "d5104900-3029-4aa6-b4e6-b61d0f14d680",
"type": "p",
"value": "XXXXXXXXXXXX",
"name": "Bob's iPhone",
"date_created": "1503020719"
},
{
"id": "b56b2b87-203d-41b7-bf45-d586daba00ed",
"type": "t",
"value": "5555555",
"name": "Bob's Dumb Phone",
"date_created": "1503020719"
},
],
"errors": null,
"meta": {
// meta info
}
}
Returns a single notification by id.
GET /notifications/:notification_id
{
"success": true,
"result": [
{
"id": "b56b2b87-203d-41b7-bf45-d586daba00ed",
"type": "t",
"value": "5555555",
"name": "Bob's Dumb Phone",
"date_created": "1503020719"
}
],
"errors": null,
"meta": {
// meta info
}
}
Deletes given notification method.
DELETE /notifications/:notification_id
{
"success": true,
"result": {
"id": "f62a955d-7f06-422d-90fd-af2cd9092d31",
"deleted_on": "1503020858",
},
"errors": null,
"meta": {
// meta info
}
}
Code | Status | Description |
---|---|---|
200 | OK | Request successful |
400 | Bad Request | Request invalid |
401 | Unauthorized | User doesn't have permission |
403 | Forbidden | Request not authenticated |
404 | Not Found | Endpoint Not Found |
405 | Method Not Allowed | Incorrect HTTP method |
409 | Conflict | User already exists |
415 | Unsupported Media Type | Request was invalid JSON |
418 | I'm a tea pot | |
429 | Too Many Requests | Auth_token was rate limited |
Code | Description |
---|---|
1001 | Incorrect email or password |
1002 | Returned if password is not set when email is or vice versa |
1003 | Returned if new_password , new_password_repeated or old_password are not all set |
1004 | Bad behavior warning. Returned if caller is doing something that constitutes bad behavior |
1005 | Trip not active |
1006 | User not premium. Txt notification method cannot be added. |
1007 | No notification id specified and no default firebase |
- Ask user whether they would like to subscribe to a bus, train or ferry
- Prompt the user to search
- Split user search into an array of each word
- POST
route_type
andparams
to/routes/search
- Display returned routes to user and let them select one
- Call
/routes/:id/trips
on the selected route, using its Delay id - Prompt user for days they are interested in, save these as
days
for later - Display only trips matching the given days
- Show users
trip_begin
andtrip_end
and prompt them to select the time frame their trip falls into - Display to the user all stops and stop times for the trip that matches the chosen time frame
- POST
stop_time_id
andtrip_id
along withdays
to/subscriptions
to create a new subscription
This JSON API does not conform to a specific standard. It takes inspiration from jsonapi.org and Cloudflare's apis.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License