Skip to content

Commit f5d698f

Browse files
committed
Clarify Provider API responses
The trips and status changes endpoints are expected to return HTTP 404 responses when data "does not exist". I'm trying to clarify that that means the future and hours when the provider was not in operation in the municipality. For past hours during which the provider was operating but nothing happened they should return "200 OK" responses with empty arrays of trips or status changes. Additionally, for hours that are not available in the API because the data is still be processed the API shall return a "102 Processing" response to indicate the requester should check back later.
1 parent a70b168 commit f5d698f

1 file changed

Lines changed: 50 additions & 12 deletions

File tree

provider/README.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,33 @@ The `/trips` API should allow querying trips with the following query parameters
185185
| --------------- | ------ | --------------- |
186186
| `end_time` | `YYYY-MM-DDTHH`, an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended datetime representing an UTC hour between 00 and 23. | All trips with an end time occurring within the hour. For example, requesting `end_time=2019-10-01T07` returns all trips where `2019-10-01T07:00:00 <= trip.end_time < 2019-10-01T08:00:00` UTC. |
187187

188-
If the provider was operational during the requested hour the provider shall return
189-
a 200 response, even if there are no trips to report (in which case
190-
the response will contain an empty list of trips).
191-
If the requested hour occurs in a time period in which the provider was not operational
192-
or the hour is not yet in the past `/trips` shall return a `404 Not Found` error.
193-
194188
Without an `end_time` query parameter, `/trips` shall return a `400 Bad Request` error.
195189

190+
### Trips - Responses
191+
192+
The API's response will depend on the hour queried and the status of data
193+
processing for that hour:
194+
195+
* For hours that are not yet in the past the API shall return a `404 Not Found`
196+
response.
197+
* For hours in which the provider was not operating the API shall return a
198+
`404 Not Found` response.
199+
* For hours that are in the past but for which data is not yet available
200+
the API shall return a `102 Processing` response.
201+
* For all other hours the API shall return a `200 OK` response with a fully
202+
populated body, even for hours that contain no trips to report.
203+
If the hour has no trips to report the response shall contain an empty
204+
array of trips:
205+
206+
```json
207+
{
208+
"version": "x.y.z",
209+
"data": {
210+
"trips": []
211+
}
212+
}
213+
```
214+
196215
For the near-ish real time use cases, please use the [events][events] endpoint.
197216

198217
[Top][toc]
@@ -287,14 +306,33 @@ The `/status_changes` API should allow querying status changes with the followin
287306
| --------------- | ------ | --------------- |
288307
| `event_time` | `YYYY-MM-DDTHH`, an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended datetime representing an UTC hour between 00 and 23. | All status changes with an event time occurring within the hour. For example, requesting `event_time=2019-10-01T07` returns all status changes where `2019-10-01T07:00:00 <= status_change.event_time < 2019-10-01T08:00:00` UTC. |
289308

290-
If the provider was operational during the requested hour the provider shall return
291-
a 200 response, even if there are no status changes to report (in which case
292-
the response will contain an empty list of status changes).
293-
If the requested hour occurs in a time period in which the provider was not operational
294-
or the hour is not yet in the past `/status_changes` shall return a `404 Not Found` error.
295-
296309
Without an `event_time` query parameter, `/status_changes` shall return a `400 Bad Request` error.
297310

311+
### Status Changes - Responses
312+
313+
The API's response will depend on the hour queried and the status of data
314+
processing for that hour:
315+
316+
* For hours that are not yet in the past the API shall return a `404 Not Found`
317+
response.
318+
* For hours in which the provider was not operating the API shall return a
319+
`404 Not Found` response.
320+
* For hours that are in the past but for which data is not yet available
321+
the API shall return a `102 Processing` response.
322+
* For all other hours the API shall return a `200 OK` response with a fully
323+
populated body, even for hours that contain no status changes to report.
324+
If the hour has no status changes to report the response shall contain an
325+
empty array of status changes:
326+
327+
```json
328+
{
329+
"version": "x.y.z",
330+
"data": {
331+
"status_changes": []
332+
}
333+
}
334+
```
335+
298336
[Top][toc]
299337

300338
## Reports

0 commit comments

Comments
 (0)