Skip to content
aravindet edited this page Oct 10, 2012 · 1 revision

Retrieve a single object

GET /students/123
GET /students/123?fields=courses,courses.teacher

Fields

courses and courses.teacher are a relationships that will be retrieved from other tables and included as nested objects.

{
  "id":   "123",
  "name": "Sam",
  "dob":  "1989-02-23",
  "courses": [
    { 
      "id": "math1", 
      "name": "Math 101",
      "teacherId": "736"
      "teacher": {
        "id": "736",
        "name": "Tracy",
        "joined": "2011-08-12"
      }
    }
  ]
}

Retrieve a set of objects

GET /students/
GET /courses/id1,id2,id3
GET /teachers?joined:lt:2010-01-01&gender:m&age:gt:35&order=joined,asc&limit=0,10

Filters

Filters are specified similarly to query component, except that instead of = they use : to separate the column name, operator (optional) and value segments. For some operators (e.g. IN) value might be a comma-separated list of values. Names and values must be escaped using encodeURIComponent().

GET /courses/id1,id2,id3 is therefore just sugar for GET /courses?id:in:id1,id2,id3

Filter embedded lists

GET /students/123?fields=courses&courses.teacherId:743

Aggregate columns

GET /students?fields=count:id
GET /students?fields=count:id,age

The first query returns a single number whereas the second returns something like:

[
  { "age": 18, "count_id": 3 },
  { "age": 19, "count_id": 7 }
]

Insert an object

PUSH and PUT can be used interchangeably.

PUSH /students
PUT /students/1/courses

Update an object

PUSH /students/1

Delete an object

DELETE /students/1