You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* updated API doc to reflect implementation
* Docs changes related to datasets
* Add list of entity endpoints to changelog, add versions endpoint
* Slight rewording of docs
* Fixing typos and removing name from entity odata
---------
Co-authored-by: Kathleen Tuite <kathleen.tuite@gmail.com>
Copy file name to clipboardExpand all lines: docs/api.md
+306-8Lines changed: 306 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,24 @@ Here major and breaking changes to the API are listed by version.
33
33
### ODK Central v2023.3
34
34
35
35
**Added**:
36
+
36
37
- New endpoint [PATCH /projects/:id/datasets/:name](#reference/datasets/datasets/update-dataset-metadata) to change whether approval of Submission is required to create an Entity.
38
+
- New [Entities](#reference/entities) endpoints for richer Entity-Based Data Collection workflows. These endpoints provide ways of accessing Entities, as well as the ability to _create_, _update_ and _soft-delete_ Entities via the API!
39
+
* New endpoint [GET /projects/:id/datasets/:name/entities](#reference/entities/retrieving-entities/entities-metadata) for listing Entities within a Dataset.
40
+
* New endpoint [GET /projects/:id/datasets/:name/entities/:uuid](#reference/entities/retrieving-entities/getting-entity-details) for getting the metadata, or details, about a specific Entity.
41
+
* New endpoint [GET /projects/:id/datasets/:name/entities/:uuid/versions](#reference/entities/retrieving-entities/listing-versions) for listing the versions of an Entity.
42
+
* New endpoint [GET /projects/:id/datasets/:name/entities/:uuid/diffs](#reference/entities/retrieving-entities/getting-changes-between-versions) for getting the changes between versions of an Entity.
43
+
* New endpoint [GET /projects/:id/datasets/:name/entities/:uuid/audits](#reference/entities/retrieving-entities/entity-audit-log) for getting the server audit logs about a specific Entity.
44
+
* New endpoint [POST /projects/:id/datasets/:name/entities](#reference/entities/creating-an-entity/creating-an-entity) for creating an Entity from JSON.
45
+
* New endpoint [PATCH /projects/:id/datasets/:name/entities/:uuid](#reference/entities/updating-an-entity/updating-an-entity) for updating the data or label of an Entity.
46
+
* New endpoint [DELETE /projects/:id/datasets/:name/entities/:uuid](#reference/entities/deleting-an-entity/deleting-an-entity) for soft-deleting an Entity.
37
47
38
48
**Changed**:
49
+
39
50
- ETag support has been added for [Download Dataset](#reference/datasets/download-dataset/download-dataset) and [Download Form Attachment](#reference/forms/individual-form/downloading-a-form-attachment).
40
-
-[Dataset Metadata endpoint](#reference/datasets/datasets/dataset-metadata) also returns sanitized property names as `odataName` to match the way they will be outputted for OData.
51
+
- The format of [Download Dataset](#reference/datasets/download-dataset/download-dataset) was changed to more closely match the OData Dataset format.
52
+
- In the [OData Dataset Service](#reference/odata-endpoints/odata-dataset-service), `name` was removed because it is a duplication of an `__id` representing an Entity's UUID.
53
+
- The `properties` returned by the [Dataset Metadata endpoint](#reference/datasets/datasets/dataset-metadata) each now include a field `odataName`, which represents the way the property name will be sanitized and outputted for OData.
41
54
42
55
### ODK Central v2023.2
43
56
@@ -3057,17 +3070,16 @@ By default `approvalRequired` is `false` for the Datasets created after v2023.3.
Datasets (collections of Entities) can be used as Attachments in other Forms, but they can also be downloaded directly as a CSV file. The CSV format matches what is expected for a [select question](https://docs.getodk.org/form-datasets/#building-selects-from-csv-files) with columns for `name`, `label,` and properties. In the case of Datasets, the `name` column is the Entity's UUID, the `label` column is the human-readable Entity label populated in the Submission, and the properties are the full set of Dataset Properties for that Dataset. If any Property for an given Entity is blank (e.g. it was not captured by that Form or was left blank), that field of the CSV is blank.
3073
+
Datasets (collections of Entities) can be used as Attachments in other Forms, but they can also be downloaded directly as a CSV file.
3074
+
The CSV format closely matches the [OData Dataset Service](#reference/odata-endpoints/odata-dataset-service) format, with columns for system properties such as `__id` (the Entity UUID), `__createdAt`, `__creatorName`, etc., the Entity Label `label`, and the Dataset/Entity Properties themselves. If any Property for an given Entity is blank (e.g. it was not captured by that Form or was left blank), that field of the CSV is blank.
3061
3075
3062
3076
This endpoint supports `ETag` header, which can be used to avoid downloading the same content more than once. When an API consumer calls this endpoint, the endpoint returns a value in the ETag header. If you pass that value in the If-None-Match header of a subsequent request, then if the Dataset has not been changed since the previous request, you will receive `304 Not Modified` response; otherwise you'll get the new data.
3063
3077
3064
-
Note that as of Version 2022.3 we do not guarantee the order of the Dataset Property columns.
Version 2023.3 brings further core enhancements to Datasets and Entities, including several new endpoints for accessing information about Entities, as well as the ability to _create_, _update_, and _soft-delete_ Entities via the API.
3112
+
3113
+
An Entity is a specific person, place, or thing. Datasets represent collections of Entities. More information about how to set up and use Datasets can be found in the [Datasets](#reference/datasets) section of this documentation.
This endpoint returns a list of the Entities of a Dataset. Please note that this endpoint only returns metadata of the entities not the data. If you want to get the data of all entities then please refer to [OData Dataset Service](#reference/odata-endpoints/odata-form-service)
3119
+
3120
+
You can provide `?deleted=true` to get only deleted entities.
3121
+
3122
+
+ Parameters
3123
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3124
+
+ name: `people` (string, required) - Name of the Dataset
This returns the Entity metadata and data for every version of this Entity, in ascending creation order.
3162
+
3163
+
This endpoint supports retrieving extended metadata; provide a header `X-Extended-Metadata: true` to return a `creator` data object alongside the `creatorId` Actor ID reference.
3164
+
3165
+
+ Parameters
3166
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3167
+
+ name: `people` (string, required) - Name of the Dataset
3168
+
+ uuid: `54a405a0-53ce-4748-9788-d23a30cc3afa` (string, required) - UUID of the Entity
3169
+
3170
+
+ Response 200 (application/json)
3171
+
+ Attributes (array[Entity Version])
3172
+
3173
+
+ Response 200 (application/json; extended)
3174
+
This is the extended response
3175
+
3176
+
+ Attributes (array[Extended Entity Version])
3177
+
3178
+
+ Response 403 (application/json)
3179
+
+ Attributes (Error 403)
3180
+
3181
+
### Getting changes between Versions [GET /projects/{projectId}/datasets/{name}/entities/{uuid}/diffs]
3182
+
3183
+
This returns the changes, or edits, between different versions of an Entity. These changes are returned as an array of arrays. Between two Entities, there is an array of objects representing how each property changed. This change object contains the old and new values, as well as the property name.
3184
+
3185
+
+ Parameters
3186
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3187
+
+ name: `people` (string, required) - Name of the Dataset
3188
+
+ uuid: `54a405a0-53ce-4748-9788-d23a30cc3afa` (string, required) - UUID of the Entity
Returns [Server Audit Logs](/reference/system-endpoints/server-audit-logs) relating to an Entity. They will be returned most recent first.
3234
+
3235
+
+ Parameters
3236
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3237
+
+ name: `people` (string, required) - Name of the Dataset
3238
+
+ uuid: `54a405a0-53ce-4748-9788-d23a30cc3afa` (string, required) - UUID of the Entity
3239
+
3240
+
+ Response 200 (application/json)
3241
+
+ Attributes (array[Audit])
3242
+
3243
+
+ Response 403 (application/json)
3244
+
+ Attributes (Error 403)
3245
+
3246
+
## Creating an Entity [/projects/{projectId}/datasets/{name}/entities]
3247
+
3248
+
### Creating an Entity [POST]
3249
+
Creates an Entity in the Dataset. Request body takes the JSON representation of the Entity. It should have `uuid` and `label` property in addition to the user-defined properties of the Dataset in `data` property. For e.g.
3250
+
```
3251
+
{
3252
+
"uuid": "54a405a0-53ce-4748-9788-d23a30cc3afa",
3253
+
"label": "John Doe",
3254
+
"data": {
3255
+
"firstName": "John",
3256
+
"lastName": "Doe",
3257
+
"city": "New York",
3258
+
...
3259
+
}
3260
+
}
3261
+
```
3262
+
3263
+
Value type of all properties is `string`.
3264
+
3265
+
You can provide header `X-Action-Notes` to store the metadata about the request. The metadata can retrieved using [Entity Audit Log](#reference/entities/entity-audit-log)
3266
+
3267
+
+ Request (application/json)
3268
+
+ Attributes
3269
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3270
+
+ name: `people` (string, required) - Name of the Dataset
3271
+
3272
+
+ Body
3273
+
3274
+
{
3275
+
"uuid": "54a405a0-53ce-4748-9788-d23a30cc3afa",
3276
+
"label": "John Doe",
3277
+
"data": {
3278
+
"firstName": "John",
3279
+
"lastName": "Doe",
3280
+
"city": "New York",
3281
+
"...other properties": "...value of other properties"
3282
+
}
3283
+
}
3284
+
3285
+
+ Response 200 (application/json)
3286
+
+ Attributes (Entity)
3287
+
3288
+
+ Response 200 (application/json; extended)
3289
+
+ Attributes (Extended Entity)
3290
+
3291
+
+ Response 403 (application/json)
3292
+
+ Attributes (Error 403)
3293
+
3294
+
## Updating an Entity [/projects/{projectId}/datasets/{name}/entities/{uuid}]
3295
+
3296
+
### Updating an Entity [PATCH]
3297
+
Use this API to update one or all properties of an Entity. It will throw `400 - Bad Request` if any of the updating properties doesn't exist in the dataset.
3298
+
3299
+
To unset value of any property, you can set it to empty string (""). Setting it to `null` will throw an error.
3300
+
3301
+
+ Request (application/json)
3302
+
+ Attributes
3303
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3304
+
+ name: `people` (string, required) - Name of the Dataset
3305
+
+ uuid: `54a405a0-53ce-4748-9788-d23a30cc3afa` (string, required) - UUID of the Entity
3306
+
3307
+
+ Body
3308
+
3309
+
{
3310
+
"label": "John (88)"
3311
+
"data": {
3312
+
"firstName": "John",
3313
+
"...other properties": "...value of other properties"
3314
+
}
3315
+
}
3316
+
3317
+
+ Response 200 (application/json)
3318
+
+ Attributes (Entity)
3319
+
3320
+
+ Response 200 (application/json; extended)
3321
+
+ Attributes (Extended Entity)
3322
+
3323
+
+ Response 403 (application/json)
3324
+
+ Attributes (Error 403)
3325
+
3326
+
## Deleting an Entity [/projects/{projectId}/datasets/{name}/entities/{id}]
3327
+
3328
+
### Deleting an Entity [DELETE /projects/{projectId}/datasets/{name}/entities/{uuid}]
3329
+
3330
+
Use this API to delete an Entity. With this API, Entity is soft-deleted, which means it is still in the database and you can retreive it by passing `?deleted=true` to [GET /projects/:id/datasets/:name/entities](#reference/entities/retrieving-entities/entities-metadata). In the future, we will provide a way to restore deleted entities and purge deleted entities.
3331
+
3332
+
+ Parameters
3333
+
+ projectId: `16` (number, required) - The numeric ID of the Project
3334
+
+ name: `people` (string, required) - Name of the Dataset
3335
+
+ uuid: `54a405a0-53ce-4748-9788-d23a30cc3afa` (string, required) - UUID of the Entity
3336
+
3337
+
+ Response 200 (application/json)
3338
+
+ Attributes (Success)
3339
+
3340
+
+ Response 403 (application/json)
3341
+
+ Attributes (Error 403)
3342
+
3343
+
3094
3344
# Group OpenRosa Endpoints
3095
3345
3096
3346
[OpenRosa](https://bitbucket.org/javarosa/javarosa/wiki/OpenRosaAPI) is an API standard which accompanies the ODK XForms XML standard, allowing compliant servers and clients to use a common protocol to communicate `Form`s and `Submission`s to each other. When survey clients like ODK Collect and Enketo submit Submission data to a Form, this is the API they use.
@@ -3763,6 +4013,8 @@ The Metadata Document describes, in [EDMX CSDL](http://docs.oasis-open.org/odata
@@ -4607,4 +4859,50 @@ These are in alphabetic order, with the exception that the `Extended` versions o
4607
4859
+ name: `the.age` (string, required) - The name of the Property.
4608
4860
+ odataName: `the_age` (string, required) - The name of the property as it will appear in OData. OData property names can only contain alphanumeric characters and underscores.
4609
4861
+ publishedAt: `2018-01-21T00:04:11.153Z` (string, required) - Publishing timestamp of the form that defined this property for the first time.
4610
-
+ forms: (array[Form KeyValue]) - List of forms that create the property
4862
+
+ forms: (array[Form KeyValue]) - List of forms that create the property
4863
+
4864
+
## Entity Summary Fields (object)
4865
+
+ uuid: `uuid:85cb9aff-005e-4edd-9739-dc9c1a829c44` (string, required) - The `uuid` of the Entity that uniquely identifies the Entity.
4866
+
+ createdAt: `2018-01-19T23:58:03.395Z` (string, required) - ISO date format. The time that the server received the Entity.
4867
+
+ updatedAt: `2018-03-21T12:45:02.312Z` (string, optional) - Timestamp of the last update in ISO date format. `null` when there is only one version of the Entity.
4868
+
+ deletedAt: `2018-03-21T12:45:02.312Z` (string, optional) - Timestamp of the deletion in ISO date format. `null` if the Entity is not deleted.
4869
+
+ creatorId: `1` (number, required) - The ID of the Actor (App User, User, or Public Link) that originally created the Entity.
4870
+
4871
+
## Entity Version Fields (object)
4872
+
+ label: `John (88)` (string, required) - Label of the Entity
4873
+
+ current: `true` (boolean, required) - `true` if the version is the latest one
4874
+
+ createdAt: `2018-03-21T12:45:02.312Z` (string, required) - Timestamp in ISO format
4875
+
+ creatorId: `1` (number, required) - The ID of the Actor (App User, User, or Public Link) that created this version.
4876
+
+ userAgent: `Enketo/3.0.4` (string, optional) - The self-identified `userAgent` of the device that created the `Entity` version.
4877
+
4878
+
## Extended Entity Version Summary (Entity Version Fields)
4879
+
+ creator: (Actor, required) - The full details of the Actor that created the Entity.
4880
+
4881
+
## Entity Summary (Entity Summary Fields)
4882
+
+ currentVersion: (Entity Version Fields, required) - Current version of the Entity
0 commit comments