Skip to main content
Version: 2.x

RESTful Flavor API

The RESTful flavor of API is designed to rigorously follow the RESTful conventions - resources, verbs, and links for further navigation based on the result dataset. It's a good choice if you want to expose a formal RESTful API to your client. The API adopts JSON:API as data format.

Here are a few examples of how to use the REST flavor of API:

// find all posts
GET /api/model/post
=>
{
"jsonapi": { "version": "1.0" },
"data": [
{ "type": "post", "id": "1", "attributes": { "title": "Hello World", ... }, ... },
...
],
...
}

// find all published posts
GET /api/model/post?filter[published]=true
=>
{
"jsonapi": { "version": "1.0" },
"data": [
{ "type": "post", "id": "1", "attributes": { "title": "Hello World", ... }, ... },
...
],
...
}

// find all posts with their authors
GET /api/model/post?include=author
=>
{
"jsonapi": { "version": "1.0" },
"data": [
{
"type": "post",
"id": "1",
"attributes": { "title": "Hello World", ... },
"relationships": {
"author": { "data": { "type": "user", "id": "1" } }
}
},
...
],
"included": [
{ "type": "user", "id": "1", "attributes": { "name": "Joey", ... } },
...
],
...
}

// create a post for user#1
POST /api/model/post
{
"data": {
"type": "post",
"attributes": {
"title": "Hello World"
},
"relationships": {
"author": { "data": { "type": "user", "id": "1" } }
}
}
}

// update a post
PATCH /api/model/post/1
{
"data": {
"type": "post",
"id": "1",
"attributes": {
"title": "Hello New World!"
}
}
}

// delete a post
DELETE /api/model/post/1

You can find the complete API reference here.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below