blob: 08e725099bc86552b41dcdaaa9a7abb84261a2fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# JSON:API
JSON:API is a specification for how a client should request that resources be
fetched or modified, and how a server should respond to those requests.
JSON:API is designed to minimize both the number of requests and the amount of
data transmitted between clients and servers.
Clients must send all JSON:API data in request documents with the header
`Content-Type: application/vnd.api+json`.
Clients that include JSON:API media type in their `Accept` header must specify
it.
Servers must send `Content-Type: application/vnd.api+json` in the response
headers.
JSON object must be at the root of every JSON:API request and response.
A document must contain at least one of the following:
* `data`: The documents primary data.
* `errors`: an array of error objects
* `meta`: a meta object that contains non-standard meta-information.
A document may contain any of:
* `jsonapi`: an object describing the server's implementation
* `links`: a links object related to the primary data.
* `self`: the link that generated the current response document
* `related`: A related resource link
* `pagination` links for the primary data.
* `included`: an array of resource objects that are related to the primary data.
* if `data` is not included then `included` must not be presented.
Resource objects must have:
* `id`: not required when sent from client
* `type`:
Resource objects may have:
* `attributes`: represents some of the resources data
* `relationships`: describing relationships between the resource and other
JSON:API resources.
* `links`: containing links related to the resource.
* `meta`: containing non-standard meta-information about a resource that cannot
be represented as an attribute or relationship.
```json
{
"meta": {
"authors": [
"x y"
]
},
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "How to make soap"
},
"relationships": {
"author": {
"links": {
"self": "/articles/1/relationships/author",
"related": "/articles/1/author"
},
"data": {
"type": "people",
"id": "9"
}
}
},
"links": {
"self": "https://example.com/articles/1"
}
}
}
```
|