-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Reference
All API access is over HTTPS, and accessed via the http://localhost:8000/api domain. The relative path prefix /v1/ indicates that we are currently using version 1 of the API.
- /spaces/<spacename>/objects/<objectId>
- POST
Creating Objects
- GET
Retrieving Objects
- PUT
Updating Objects
- DELETE
Deleting Objects
- POST
To create a new object on Parse, send a POST request to the class URL containing the contents of the object. For example, to create the object described above:
curl -X POST \ -H "X_CDS_Client_Id:{client_id}" \ -H "X_CDS_Client_Key:{client_key}" \ -H "Content-Type:application/json" \ -d '{"name":"St.Mandy mile melo", "location":{"lat":40.12,"lon":-71.34}}' \ http://localhost:8000/api/v1/spaces/shop/objects
When the creation is successful, the HTTP response is a 201 Created and the Location header contains the object URL for the new object:
Status: 201 Created Location: https://localhost:8000/v1/spaces/shop/objects/gehn_cu2SAabQIK5RvflSQ
The response body is a JSON object containing the object_id and the created_at、updated_at timestamp of the newly-created object
{ 'updated_at': '2014-01-07T08:13:15.948124', 'created_at': '2014-01-07T08:13:15.948124', 'object_id': u'gehn_cu2SAabQIK5RvflSQ' }
Once you've created an object, you can retrieve its contents by sending a GET request to the object URL returned in the location header. For example, to retrieve the object we created above:
curl -X GET \ -H "X_CDS_Client_Id:{client_id}" \ -H "X_CDS_Client_Key:{client_key}" \ http://localhost:8000/api/v1/spaces/shop/objects
The response body is a JSON object containing all the user-provided fields, plus the createdAt, updatedAt, and objectId fields:
{ "meta":{ "limit":20, "next":null, "offset":0, "previous":null, "took":52, "total_count":4 }, "objects":[ { "location":{ "lat":40.12, "lon":-71.34 }, "name":"St.Mandy mile melo", "object_id":"z6Z1sBKDTzW0saR_-vygxQ", "resource_uri":"/api/v1/spaces/shop/objects/z6Z1sBKDTzW0saR_-vygxQ", "updated_at":"2014-01-07T08:37:56.462878", "created_at":"2014-01-07T08:37:56.462878" } ] }
- URL Params
- limit
for pagination
- offset
for pagination
- order_by
eg. -created_at or created_at
- fields
split with comma(,)
- query
- limit
To change the data on an object that already exists, send a PUT request to the object URL. Any keys you don't specify will remain unchanged, so you can update just a subset of the object's data. For example, if we wanted to change the name field of our object:
curl -X PUT \ -H "X_CDS_Client_Id:{client_id}" \ -H "X_CDS_Client_Key:{client_key}" -H "Content-Type:application/json" \ -d '{"doc":{"name":"SOLANA DS-21"}, "fields":"name"}' http://localhost:8000/api/v1/spaces/shop/objects/{object_id}
The response body is a JSON object containing updated_at field with the timestamp of the update and other defined in fields.
{ "name":"SOLANA DS-21", "object_id":"gehn_cu2SAabQIK5RvflSQ", "resource_uri":"/api/v1/spaces/shop/objects/gehn_cu2SAabQIK5RvflSQ", "updated_at":"2014-01-07T09:33:01.411659" }
To delete an object from the CDS, send a DELETE request to its object URL. For example:
curl -X DELETE \ -H "X_CDS_Client_Id:a7233b4e3240dad3d9a2167f069e4154bf067786" \ -H "X_CDS_Client_Key:8750617a14f4ad854cf358975d5f648c08769da316b9c6c1" \ http://localhost:8000/api/v1/spaces/shop/objects/{object_id}