-
Notifications
You must be signed in to change notification settings - Fork 2
REST API
aravindet edited this page Oct 10, 2012
·
1 revision
GET /students/123
GET /students/123?fields=courses,courses.teacher
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"
}
}
]
}
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 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
GET /students/123?fields=courses&courses.teacherId:743
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 }
]
PUSH
and PUT
can be used interchangeably.
PUSH /students
PUT /students/1/courses
PUSH /students/1
DELETE /students/1