Records¶
Records belong to a collection. It is the data being stored and synchronised.
Uploading a record¶
-
POST
/buckets/
(bucket_id)/collections/
(collection_id)/records
¶ synopsis: Store a record in the collection. The ID will be assigned automatically. Requires authentication
Example Request
$ echo '{"data": {"foo": "bar"}}' | http post http://localhost:8888/v1/buckets/blog/collections/articles/records --auth="bob:" --verbose
POST /v1/buckets/blog/collections/articles/records HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Content-Length: 25 Content-Type: application/json Host: localhost:8888 User-Agent: HTTPie/0.9.2 { "data": { "foo": "bar" } }
Example Response
HTTP/1.1 201 Created Access-Control-Expose-Headers: Backoff, Retry-After, Alert Content-Length: 199 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:02:23 GMT Server: waitress { "data": { "foo": "bar", "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434646943915 }, "permissions": { "write": [ "basicauth:206691a25679e4e1135f16aa77ebcf211c767393c4306cfffe6cc228ac0886b6" ] } }
Replacing a record¶
-
PUT
/buckets/
(bucket_id)/collections/
(collection_id)/records/
(record_id)¶ Synopsis: Create or update a record in the collection. Requires authentication
Example Request
$ echo '{"data": {"foo": "baz"}}' | http put http://localhost:8888/v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 --auth="bob:" --verbose
PUT /v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Content-Length: 25 Content-Type: application/json Host: localhost:8888 User-Agent: HTTPie/0.9.2 { "data": { "foo": "baz" } }
Example Response
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert Content-Length: 199 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:16:22 GMT Server: waitress { "data": { "foo": "baz", "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434647782623 }, "permissions": { "write": [ "basicauth:206691a25679e4e1135f16aa77ebcf211c767393c4306cfffe6cc228ac0886b6" ] } }
Updating a record¶
-
PATCH
/buckets/
(bucket_id)/collections/
(collection_id)/records/
(record_id)¶ Synopsis: Update a record in the collection. Specify only the fields to be modified (all the rest will remain intact). Requires authentication
Example Request
$ echo '{"data": {"status": "done"}}' | http patch http://localhost:8888/v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 --auth="bob:" --verbose
PATCH /v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 HTTP/1.1 Accept: application/json Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Content-Length: 25 Content-Type: application/json Host: localhost:8888 User-Agent: HTTPie/0.9.2 { "data": { "status": "done" } }
Example Response
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert Content-Length: 211 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:19:56 GMT Server: waitress { "data": { "status": "done", "title": "Midnight in Paris", "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434647996969 }, "permissions": { "write": [ "basicauth:206691a25679e4e1135f16aa77ebcf211c767393c4306cfffe6cc228ac0886b6" ] } }
Retrieving stored records¶
Records can be paginated and filtered, and conflicts can be detected.
To do so, refer to Resource endpoints for more details on available operations on collection retrieval.
-
GET
/buckets/
(bucket_id)/collections/
(collection_id)/records
¶ Synopsis: Retrieve all the records in the collection. Requires authentication
Example Request
$ http get http://localhost:8888/v1/buckets/blog/collections/articles/records --auth="bob:" --verbose
GET /v1/buckets/blog/collections/articles/records HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Host: localhost:8888 User-Agent: HTTPie/0.9.2
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert, Next-Page, Total-Records, Last-Modified, ETag Content-Length: 110 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:24:38 GMT Etag: "1434648278603" Last-Modified: Thu, 18 Jun 2015 17:24:38 GMT Server: waitress Total-Records: 1 { "data": [ { "baz": "bar", "foo": "baz", "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434647996969 } ] }
Retrieving a specific record¶
-
GET
/buckets/
(bucket_id)/collections/
(collection_id)/records/
(record_id)¶ Synopsis: Retrieve a specific record by its ID. Requires authentication
Example Request
$ http get http://localhost:8888/v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 --auth="bob:" --verbose
GET /v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Host: localhost:8888 User-Agent: HTTPie/0.9.2
Example Response
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert, Last-Modified, ETag Content-Length: 211 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:29:59 GMT Etag: "1434648599199" Last-Modified: Thu, 18 Jun 2015 17:29:59 GMT Server: waitress { "data": { "baz": "bar", "foo": "baz", "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434647996969 }, "permissions": { "write": [ "basicauth:206691a25679e4e1135f16aa77ebcf211c767393c4306cfffe6cc228ac0886b6" ] } }
Delete stored records¶
-
DELETE
/buckets/
(bucket_id)/collections/
(collection_id)/records
¶ Synopsis: Delete all the records in the collection. Requires authentication
Example Request
$ http delete http://localhost:8888/v1/buckets/blog/collections/articles/records --auth="bob:" --verbose
DELETE /v1/buckets/blog/collections/articles/records HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Host: localhost:8888 User-Agent: HTTPie/0.9.2
Example Response
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert, Last-Modified, ETag Content-Length: 211 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:29:59 GMT Etag: "1434648599199" Last-Modified: Thu, 18 Jun 2015 17:29:59 GMT Server: waitress { "data": [{ "deleted": true, "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434648749173 }] }
Deleting a single record¶
-
DELETE
/buckets/
(bucket_id)/collections/
(collection_id)/records/
(record_id)¶ Synopsis: Delete a record by its ID. Example Request
$ http delete http://localhost:8888/v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 --auth="bob:" --verbose
DELETE /v1/buckets/blog/collections/articles/records/89881454-e4e9-4ef0-99a9-404d95900352 HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Authorization: Basic Ym9iOg== Connection: keep-alive Content-Length: 0 Host: localhost:8888 User-Agent: HTTPie/0.9.2
Example Response
HTTP/1.1 200 OK Access-Control-Expose-Headers: Backoff, Retry-After, Alert Content-Length: 99 Content-Type: application/json; charset=UTF-8 Date: Thu, 18 Jun 2015 17:32:29 GMT Server: waitress { "data": { "deleted": true, "id": "89881454-e4e9-4ef0-99a9-404d95900352", "last_modified": 1434648749173 } }