Skip to content

Commit baefada

Browse files
authored
Merge pull request #830 from openmobilityfoundation/feature-agency-provider-tweaks
Agency Provider Structure Tweaks
2 parents 32ec82d + 158a63f commit baefada

4 files changed

Lines changed: 167 additions & 133 deletions

File tree

agency/README.md

Lines changed: 82 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ This specification contains a collection of RESTful APIs used to specify the dig
1515
* [Authorization](#authorization)
1616
* [GBFS](#gbfs)
1717
* [Vehicles](#vehicles)
18+
* [Vehicle - Status](#vehicle---status)
1819
* [Vehicle - Register](#vehicle---register)
1920
* [Vehicle - Update](#vehicle---update)
20-
* [Vehicles - Events](#vehicles---events)
21-
* [Vehicles - Telemetry](#vehicles---telemetry)
2221
* [Trips](#trips)
22+
* [Telemetry](#telemetry)
23+
* [Events](#events)
2324
* [Stops](#stops)
2425
* [Stops - Register](#stops---register)
2526
* [Stops - Update](#stops---update)
@@ -67,10 +68,11 @@ See the [GBFS Requirement](/README.md#gbfs-requirement) language for more detail
6768

6869
## Vehicles
6970

70-
The `/vehicles` endpoint returns the specified vehicle (if a device_id is provided) or a list of known vehicles. Providers can only retrieve data for vehicles in their registered fleet.
71+
The `/vehicles` endpoint returns the specified vehicle (if a device_id is provided) or a list of known vehicles. Providers can only retrieve data for vehicles in their registered fleet. Contains vehicle properties that do not change often.
7172

72-
Endpoint: `/vehicles/{device_id}`
73-
Method: `GET`
73+
**Endpoint**: `/vehicles/{device_id}`
74+
**Method:** `POST`
75+
**Payload:** An array of [Vehicles](/data-types.md#vehicles)
7476

7577
Path Params:
7678

@@ -100,17 +102,53 @@ _No content returned on vehicle not found._
100102

101103
[Top][toc]
102104

103-
## Vehicle - Register
105+
### Vehicle - Status
106+
107+
The `/vehicles/status` endpoint returns information about the specified vehicle (if a device_id is provided) or a list of known vehicles current state. Providers can only retrieve data for vehicles in their registered fleet. Contains specific vehicle properties that are updated frequently.
108+
109+
**Endpoint**: `/vehicles/status/{device_id}`
110+
**Method:** `POST`
111+
**Payload:** An array of [Vehicles](/data-types.md#vehicle-status) objects
112+
113+
Path Params:
114+
115+
| Param | Type | Required/Optional | Description |
116+
| ------------ | ---- | ----------------- | ------------------------------------------- |
117+
| `device_id` | UUID | Optional | If provided, retrieve the specified vehicle |
118+
119+
200 Success Response:
120+
121+
If `device_id` is specified, `GET` will return an array with a vehicle status record, otherwise it will be a list of vehicle records with pagination details per the [JSON API](https://jsonapi.org/format/#fetching-pagination) spec:
122+
123+
```json
124+
{
125+
"vehicles_status": [ ... ]
126+
"links": {
127+
"first": "https://...",
128+
"last": "https://...",
129+
"prev": "https://...",
130+
"next": "https://..."
131+
}
132+
}
133+
```
134+
135+
404 Failure Response:
136+
137+
_No content returned on vehicle not found._
138+
139+
[Top][toc]
140+
141+
### Vehicle - Register
104142

105143
The `/vehicles` registration endpoint is used to register vehicles for use in the Agency's jurisdiction.
106144

107145
**Endpoint**: `/vehicles`
108146
**Method:** `POST`
109-
**Payload:** An array of [Vehicles](#vehicle)
147+
**Payload:** An array of [Vehicles](/data-types.md#vehicles)
110148

111149
200 Success Response:
112150

113-
See [Bulk Responses](#bulk-responses)
151+
See [Bulk Responses][bulk-responses]
114152

115153
[Top][toc]
116154

@@ -126,17 +164,17 @@ See [Bulk Responses](#bulk-responses)
126164

127165
**None**
128166

129-
## Vehicle - Update
167+
### Vehicle - Update
130168

131169
The `/vehicles` update endpoint is used to change vehicle information, should some aspect of the vehicle change, such as the `vehicle_id`. Each vehicle must already be registered.
132170

133171
**Endpoint**: `/vehicles`
134172
**Method:** `PUT`
135-
**Payload:** An array of [Vehicles](#vehicle)
173+
**Payload:** An array of [Vehicles](/data-types.md#vehicles)
136174

137175
200 Success Response:
138176

139-
See [Bulk Responses](#bulk-responses)
177+
See [Bulk Responses][bulk-responses]
140178

141179
### Vehicle Update Error Codes:
142180

@@ -147,39 +185,42 @@ See [Bulk Responses](#bulk-responses)
147185

148186
[Top][toc]
149187

150-
## Vehicles - Events
188+
## Trips
151189

152-
The vehicle `/events` endpoint allows the Provider to submit events describing the state changes of multiple vehicles.
190+
The Trips endpoint serves two purposes:
153191

154-
**Endpoint:** `/vehicles/events`
192+
* Definitively indicating that a Trip (a sequence of events linked by a trip_id) has been completed. For example, from analyzing only the raw Vehicle Events feed, if a trip crosses an Agency's jurisdictional boundaries but does not end within the jurisdiction (last event_type seen is a `leave_jurisdiction`), this can result in a 'dangling trip'. The Trips endpoint satisfies this concern, by acting as a final indication that a trip has been finished, even if it ends outside of jurisdictional boundaries; if a trip has intersected an Agency's jurisdictional boundaries at all during a trip, it is expected that a Provider will send a Trip payload to the Agency following the trip's completion.
193+
* Providing information to an Agency regarding an entire trip, without extending any of the Vehicle Event payloads, or changing any requirements on when Vehicle Events should be sent.
194+
195+
**Endpoint:** `/trips`
155196
**Method:** `POST`
156-
**Payload:** An array of [Vehicle Events](#vehicle-event)
197+
**Payload:** Array of [Trips](/data-types.md#trips)
157198

158199
200 Success Response:
159200

160-
See [Bulk Responses](#bulk-responses)
201+
See [Bulk Responses][bulk-responses]
161202

162-
### Event Errors:
203+
### Trip Errors:
163204

164-
| `error` | `error_description` | `error_details`[] |
165-
| ------- | ------------------- | ----------------- |
166-
| `bad_param` | A validation error occurred | Array of parameters with errors |
167-
| `missing_param` | A required parameter is missing | Array of missing parameters |
168-
| `unregistered` | This `device_id` is unregistered | |
205+
| `error` | `error_description` | `error_details`[] |
206+
| -------------------- | ------------------------------------------------- | ------------------------------- |
207+
| `bad_param` | A validation error occurred | Array of parameters with errors |
208+
| `missing_param` | A required parameter is missing | Array of missing parameters |
209+
| `unregistered` | This `device_id` is unregistered | |
169210

170211
[Top][toc]
171212

172-
## Vehicles - Telemetry
213+
## Telemetry
173214

174215
The vehicle `/telemetry` endpoint allows a Provider to send vehicle telemetry data in a batch for any number of vehicles in the fleet.
175216

176-
**Endpoint**: `/vehicles/telemetry`
217+
**Endpoint**: `/telemetry`
177218
**Method**: `POST`
178-
**Payload**: An array of [Vehicle Telemetry][vehicle-telemetry]
219+
**Payload**: An array of vehicle [Telemetry][vehicle-telemetry]
179220

180221
200 Success Response:
181222

182-
See [Bulk Responses](#bulk-responses)
223+
See [Bulk Responses][bulk-responses]
183224

184225
### Telemetry Errors:
185226

@@ -191,28 +232,25 @@ See [Bulk Responses](#bulk-responses)
191232

192233
[Top][toc]
193234

194-
## Trips
195-
196-
The Trips endpoint serves two purposes:
235+
## Events
197236

198-
* Definitively indicating that a Trip (a sequence of events linked by a trip_id) has been completed. For example, from analyzing only the raw Vehicle Events feed, if a trip crosses an Agency's jurisdictional boundaries but does not end within the jurisdiction (last event_type seen is a `leave_jurisdiction`), this can result in a 'dangling trip'. The Trips endpoint satisfies this concern, by acting as a final indication that a trip has been finished, even if it ends outside of jurisdictional boundaries; if a trip has intersected an Agency's jurisdictional boundaries at all during a trip, it is expected that a Provider will send a Trip payload to the Agency following the trip's completion.
199-
* Providing information to an Agency regarding an entire trip, without extending any of the Vehicle Event payloads, or changing any requirements on when Vehicle Events should be sent.
237+
The vehicle `/events` endpoint allows the Provider to submit events describing the state changes of multiple vehicles.
200238

201-
**Endpoint:** `/trips`
239+
**Endpoint:** `/events`
202240
**Method:** `POST`
203-
**Payload:** Array of [Trips](#trip-data)
241+
**Payload:** An array of vehicle [Events](/data-types.md#events)
204242

205243
200 Success Response:
206244

207-
See [Bulk Responses](#bulk-responses)
245+
See [Bulk Responses][bulk-responses]
208246

209-
### Trip Errors:
247+
### Event Errors:
210248

211-
| `error` | `error_description` | `error_details`[] |
212-
| -------------------- | ------------------------------------------------- | ------------------------------- |
213-
| `bad_param` | A validation error occurred | Array of parameters with errors |
214-
| `missing_param` | A required parameter is missing | Array of missing parameters |
215-
| `unregistered` | This `device_id` is unregistered | |
249+
| `error` | `error_description` | `error_details`[] |
250+
| ------- | ------------------- | ----------------- |
251+
| `bad_param` | A validation error occurred | Array of parameters with errors |
252+
| `missing_param` | A required parameter is missing | Array of missing parameters |
253+
| `unregistered` | This `device_id` is unregistered | |
216254

217255
[Top][toc]
218256

@@ -228,7 +266,7 @@ The `/stops` endpoint allows an agency to register city-managed Stops, or a prov
228266

229267
200 Success Response:
230268

231-
See [Bulk Responses](#bulk-responses)
269+
See [Bulk Responses][bulk-responses]
232270

233271
#### Stops Register Errors:
234272

@@ -258,7 +296,7 @@ See [Bulk Responses](#bulk-responses)
258296

259297
200 Success Response:
260298

261-
See [Bulk Responses](#bulk-responses)
299+
See [Bulk Responses][bulk-responses]
262300

263301
#### Stops update Errors:
264302

@@ -296,7 +334,7 @@ The authenticated reports are monthly, historic flat files that may be pre-gener
296334

297335
[Top][toc]
298336

299-
## Reports - register
337+
## Reports - Register
300338

301339
The `/reports` endpoint allows an agency to register aggregated report counts in CSV structure.
302340

@@ -306,7 +344,7 @@ The `/reports` endpoint allows an agency to register aggregated report counts in
306344

307345
200 Success Response:
308346

309-
See [Bulk Responses](#bulk-responses)
347+
See [Bulk Responses][bulk-responses]
310348

311349
#### Reports Register Errors:
312350

data-types.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This MDS data types page catalogs the objects (fields, types, requirements, desc
77
- [Vehicles](#vehicles)
88
- [Vehicle Types](#vehicle-types)
99
- [Propulsion Types](#propulsion-types)
10-
- [Vehicle Status](#vehicle-status)
10+
- [Vehicle Status](#vehicle-status)
1111
- [Events](#events)
1212
- [Event Types](#event-times)
1313
- [Telemetry](#telemetry)
@@ -65,7 +65,7 @@ A vehicle may have one or more values from the `propulsion`, depending on the nu
6565

6666
[Top][toc]
6767

68-
## Vehicle Status
68+
### Vehicle Status
6969

7070
A vehicle status record represents the current or last-known event and telemetry from a vehicle, defined as follows:
7171

@@ -113,14 +113,14 @@ A standard point of vehicle telemetry. References to latitude and longitude impl
113113

114114
| Field | Type | Required/Optional | Field Description |
115115
| ----- | ---- | ----------------- | ----------------- |
116-
| `device_id` | UUID | Required | ID used in [Register](#vehicle---register) |
116+
| `device_id` | UUID | Required | A unique device ID in UUID format |
117117
| `provider_id` | UUID | Required | A UUID for the Provider, unique within MDS. See MDS [provider list](/providers.csv). |
118118
| `data_provider_id`| UUID | Optional | If different than `provider_id`, a UUID for the data solution provider managing the data feed in this endpoint. See MDS [provider list](/providers.csv) which includes both service operators and data solution providers. |
119119
| `telemetry_id` | UUID | Required | ID used for uniquely-identifying a Telemetry entry |
120120
| `timestamp` | [Timestamp][ts] | Required | Date/time that event occurred. Based on GPS or GNSS clock |
121121
| `trip_ids` | UUID[] | Required | If telemetry occurred during a trip, the ID of the trip(s). If not in a trip, `null`.
122122
| `journey_id` | UUID | Required | If telemetry occurred during a trip, the ID of the journey. If not in a trip, `null`.
123-
| `stop_id` | UUID | Required if Applicable | Stop that the vehicle is currently located at. Only applicable for _docked_ Micromobility. See [Stops][stops] |
123+
| `stop_id` | UUID | Required if Applicable | Stop that the vehicle is currently located at. See [Stops][stops] |
124124
| `location` | [GPS][gps] | Required | Telemetry position data |
125125
| `location_type` | Enum | Required if Known | If detectable and known, what type of location the device is on or in. One of `street`, `sidewalk`, `crosswalk`, `garage`, `bike_lane`. |
126126
| `battery_percent` | Integer | Required if Applicable | Percent battery charge of vehicle, expressed between 0 and 100 |
@@ -144,7 +144,7 @@ A standard point of vehicle telemetry. References to latitude and longitude impl
144144

145145
## Stops
146146

147-
Stops describe vehicle trip start and end locations in a pre-designated physical place. They can vary from docking stations with or without charging, corrals with lock-to railings, or suggested parking areas marked with spray paint. Stops are used in both [Provider](/provider#stops) (including routes and event locations) and [Agency](/agency#stops) (including telemetry data).
147+
Stops describe vehicle trip start and end locations in a pre-designated physical place. They can vary from docking stations with or without charging, corrals with lock-to railings, or suggested parking areas marked with spray paint. Stops are used in both [Provider](/provider#stops) and [Agency](/agency#stops) telemetry data.
148148

149149
| Field | Type | Required/Optional | Description |
150150
| ----- | ---- |-------------------|-------------|

general-information.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ This document contains specifications that are shared between the various MDS [A
1010
- [Data Types](#data-types)
1111
- [Definitions](#definitions)
1212
- [Devices](#devices)
13+
- [GBFS Compatibility](#gbfs-compatibility)
1314
- [Geographic Data](#geographic-data)
14-
- [Geographic Telemetry Data](#geographic-telemetry-data)
15-
- [Stop-based Geographic Data](#stop-based-geographic-data)
1615
- [Intersection Operation](#intersection-operation)
1716
- [Geography-Driven Events](#geography-driven-events)
1817
- [Responses](#responses)
1918
- [Error Messages](#error-messages)
19+
- [Bulk Responses](#bulk-responses)
20+
- [Failure Details](#failure-details)
2021
- [Strings](#strings)
2122
- [Timestamps](#timestamps)
23+
- [Trips](#trips)
2224
- [UUIDs](#uuids)
25+
- [Vehicle States](#vehicle-states)
2326
- [Versioning](#versioning)
2427

2528
## Authentication
@@ -42,7 +45,7 @@ Working Groups and their Steering Committees are expected to review beta designa
4245

4346
[Top][toc]
4447

45-
## Costs and currencies
48+
## Costs and Currencies
4649

4750
Fields specifying a monetary cost use a currency as specified in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217#Active_codes). All costs should be given as integers in the currency's smallest unit. As an example, to represent $1 USD, specify an amount of `100` (100 cents).
4851

@@ -76,6 +79,12 @@ Additionally, `device_id` must remain constant for the device's lifetime of serv
7679

7780
[Top][toc]
7881

82+
## GBFS Compatibility
83+
84+
Some of the fields in the `Stops` definition are using notions which are currently not in MDS, such as `rental_methods`. These fields are included for compatibility with GBFS.
85+
86+
[Top][toc]
87+
7988
## Geographic Data
8089

8190
References to geographic datatypes (Point, MultiPolygon, etc.) imply coordinates encoded in the [WGS 84 (EPSG:4326)][wgs84] standard GPS or GNSS projection expressed as [Decimal Degrees][decimal-degrees]. When points are used, you may assume a 20 meter buffer around the point when needed.
@@ -169,7 +178,7 @@ For multi-record POST and PUT calls, e.g. sending Events using the Agency API, t
169178
| `total` | Integer | Total number of provided points |
170179
| `failures` | [Trip](#trip-data)[] | Array of failed trip records (empty if all successful) |
171180

172-
### Failure Details:
181+
### Failure Details
173182

174183
| Field | Type | Field Description |
175184
| ----- | ---- | ----------------- |
@@ -186,26 +195,12 @@ All String fields, such as `vehicle_id`, are limited to a maximum of 255 charact
186195

187196
[Top][toc]
188197

189-
### GBFS Compatibility
190-
191-
Some of the fields in the `Stops` definition are using notions which are currently not in MDS, such as `rental_methods`. These fields are included for compatibility with GBFS.
192-
193-
[Top][toc]
194-
195198
## Timestamps
196199

197200
A `timestamp` refers to integer milliseconds since Unix epoch.
198201

199202
[Top][toc]
200203

201-
## UUIDs
202-
203-
Object identifiers are described via Universally Unique Identifiers [(UUIDs)](https://en.wikipedia.org/wiki/Universally_unique_identifier). For example, the `device_id` field used to uniquely identify a vehicle is a UUID.
204-
205-
MDS uses Version 1 UUIDs by default. Version 4 UUIDs may be used where noted.
206-
207-
[Top][toc]
208-
209204
## Trips
210205

211206
Counting trips is a common analysis with MDS data, but in some instances when
@@ -223,6 +218,14 @@ at the recommendation of the MDS community when analyzing trips.
223218

224219
[Top][toc]
225220

221+
## UUIDs
222+
223+
Object identifiers are described via Universally Unique Identifiers [(UUIDs)](https://en.wikipedia.org/wiki/Universally_unique_identifier). For example, the `device_id` field used to uniquely identify a vehicle is a UUID.
224+
225+
MDS uses Version 1 UUIDs by default. Version 4 UUIDs may be used where noted.
226+
227+
[Top][toc]
228+
226229
## Vehicle States
227230

228231
See new location within [vehicle states](/modes/vehicle_states.md) in [modes](/modes#vehicle-states).
@@ -253,12 +256,12 @@ MDS APIs must handle requests for specific versions of the specification from cl
253256

254257
Versioning must be implemented through the use of a custom media-type, `application/vnd.mds+json`, combined with a required `version` parameter. The one exception is the `/reports` endpoint, which returns CSV files instead of JSON, and so uses `text/vnd.mds+csv` as its media-type.
255258

256-
The version parameter specifies the dot-separated combination of major and minor versions from a published version of the specification. For example, the media-type for version `1.0.1` would be specified as `application/vnd.mds+json;version=1.0`
259+
The version parameter specifies the dot-separated combination of major and minor versions from a published version of the specification. For example, the media-type for version `1.0.1` would be specified as `application/vnd.mds+json;version=1.0`. Only major and minor versions are allowed and required in the media-type version string (not [patch](https://github.com/openmobilityfoundation/governance/blob/main/technical/ReleaseGuidelines.md#versioning) releases).
257260

258261
Clients must specify the version they are targeting through the `Accept` header. For example:
259262

260263
```http
261-
Accept: application/vnd.mds+json;version=1.2.0
264+
Accept: application/vnd.mds+json;version=2.0
262265
```
263266

264267
Since versioning was not available from the start, the following APIs provide a fallback version if the `Accept` header is not set as specified above:

0 commit comments

Comments
 (0)