Add a new resource.
URL: http://localhost:10200/users
Request:
Accept: application/vnd.api+json
{
"data": {
"type": "users",
"attributes": {
"email": "[email protected]",
"password": "ryan",
"gender": "m"
},
"relationships": {
"mom": {
"data": {
"type": "users",
"id": "[email protected]"
}
}
}
}
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 992
Location: http://localhost:10200/v1/users/[email protected]
Date: Tue, 15 Sep 2015 04:31:28 GMT
{
"data": {
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 16:54:19 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": {
"id": "[email protected]",
"type": "users"
},
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
},
"links": {
"self": "http://localhost:10200/v1/users/[email protected]"
}
}
Modify an existing resource.
URL: http://localhost:10200/users/[email protected]
Request:
Accept: application/vnd.api+json
{
"data": {
"type": "users",
"attributes": {
"password": "muchHarderPasswordToGuess"
}
}
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 992
Location: http://localhost:10200/v1/users/[email protected]
Date: Tue, 15 Sep 2015 04:31:28 GMT
{
"data": {
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 17:18:38 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": {
"id": "[email protected]",
"type": "users"
},
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
},
"links": {
"self": "http://localhost:10200/v1/users/[email protected]"
}
}
Deactivate an existing resource.
URL: http://localhost:10200/users/[email protected]
Request:
Accept: application/vnd.api+json
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 0
Date: Tue, 15 Sep 2015 04:31:28 GMT
Fetch an existing resource.
URL: http://localhost:10200/users/[email protected]?include=mom*
*More info on the include parameter can be found here
Request:
Accept: application/vnd.api+json
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 1050
Date: Tue, 15 Sep 2015 04:31:28 GMT
{
"data": {
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 17:18:38 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": {
"id": "[email protected]",
"type": "users"
},
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
},
"included": [
{
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "f",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 16:54:19 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": null,
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
}
],
"links": {
"self": "http://localhost:10200/v1/users/[email protected]"
}
}
Fetch a resource collection
URL: http://localhost:10200/users?page[offset]=0&page[limit]=1*
*More info on pagination can be found here
Request:
Accept: application/vnd.api+json
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 1061
Date: Tue, 15 Sep 2015 04:31:28 GMT
{
"data": [
{
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 16:54:19 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": null,
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
}
],
"links": {
"first": "http://localhost:10200/v1/users?page[offset]=0&page[limit]=1",
"last": "http://localhost:10200/v1/users?page[offset]=2&page[limit]=1",
"next": "http://localhost:10200/v1/users?page[offset]=1&page[limit]=1",
"self": "http://localhost:10200/v1/users?page[offset]=0&page[limit]=1"
}
}
Add an item to a relationship collection.
*Note: use POST for collections with MANY items, otherwise use PATCH
URL: http://localhost:10200/users/[email protected]/relationships/friends
Request:
Accept: application/vnd.api+json
{
"data": [
{
"type": "users",
"id": "[email protected]",
"meta": {
"met": "space camp"
}
}
]
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 0
Date: Tue, 15 Sep 2015 04:31:28 GMT
This method does a total replace on a relationship. It should therefore be used to create relationships with cardinality <= 1. It can also be used to delete all relationships.
URL: http://localhost:10200/v1/users/[email protected]/relationships/mom
Request to create:
Accept: application/vnd.api+json
{
"data":{"type":"users", "id":"[email protected]"}
}
Request to delete:
Accept: application/vnd.api+json
{
"data":null
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 0
Date: Tue, 15 Sep 2015 04:31:28 GMT
Use this method to delete certain relationships contained in the body. Only the relationships in the body will be deleted. This method is only for collections with cardinality > 1.
URL: http://localhost:10200/v1/users/[email protected]/relationships/friends
Request:
Accept: application/vnd.api+json
{
"data": [
{
"type": "users",
"id": "[email protected]"
}
]
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 0
Date: Tue, 15 Sep 2015 04:31:28 GMT
On collections with cardinality > 1 use this method to delete all existing items in that collection.
URL: http://localhost:10200/v1/users/[email protected]/relationships/friends
Request:
Accept: application/vnd.api+json
{
"data": []
}
Response:
Content-Type: application/vnd.api+json; charset=utf-8
Content-Length: 0
Date: Tue, 15 Sep 2015 04:31:28 GMT
Fetch a relationship.
URL: http://localhost:10200/v1/users/[email protected]/relationships/friends
Request:
Accept: application/vnd.api+json
{
"data": [
{
"id": "[email protected]",
"meta": {
"created": "Sun, 27 Sep 2015 18:16:47 GMT",
"met": "space camp",
"type": "friend",
"updated": "Sun, 27 Sep 2015 18:16:47 GMT"
},
"type": "users"
},
{
"id": "[email protected]",
"meta": {
"created": "Sun, 27 Sep 2015 18:16:47 GMT",
"met": "taco tuesday party",
"type": "friend",
"updated": "Sun, 27 Sep 2015 18:16:47 GMT"
},
"type": "users"
},
{
"id": "[email protected]",
"meta": {
"created": "Sun, 27 Sep 2015 18:16:47 GMT",
"met": "at atheist revival",
"type": "friend",
"updated": "Sun, 27 Sep 2015 18:16:47 GMT"
},
"type": "users"
}
],
"included": [
{
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 18:16:47 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 18:16:47 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [
{
"id": "[email protected]",
"type": "users"
}
],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": null,
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
},
{
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 18:16:47 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 18:16:47 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [
{
"id": "[email protected]",
"type": "users"
}
],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": null,
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
},
{
"attributes": {
"active": true,
"created": "Sun, 27 Sep 2015 16:54:19 GMT",
"email": "[email protected]",
"gender": "m",
"id": "[email protected]",
"type": "users",
"updated": "Sun, 27 Sep 2015 17:18:38 GMT"
},
"id": "[email protected]",
"relationships": {
"friends": {
"data": [
{
"id": "[email protected]",
"type": "users"
}
],
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends"
}
},
"mom": {
"data": null,
"links": {
"related": "http://localhost:10200/v1/users/[email protected]/mom",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/mom"
}
}
},
"type": "users"
}
],
"links": {
"first": "http://localhost:10200/v1/users/[email protected]/relationships/friends?page[offset]=0&page[limit]=20",
"last": "http://localhost:10200/v1/users/[email protected]/relationships/friends?page[offset]=0&page[limit]=20",
"related": "http://localhost:10200/v1/users/[email protected]/friends",
"self": "http://localhost:10200/v1/users/[email protected]/relationships/friends?page[offset]=0&page[limit]=20"
}
}