You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Data, including resources and relationships, can be fetched by sending a GET request to an endpoint.
Responses can be further refined with the optional features described below.
Fetching Resources
A server MUST support fetching resource data for every URL provided as:
a self link as part of the top-level links object
a self link as part of a resource-level links object
a related link as part of a relationship-level links object
For example, the following request fetches a collection of articles:
GET /articles HTTP/1.1Accept: application/vnd.api+json
The following request fetches an article:
GET /articles/1 HTTP/1.1Accept: application/vnd.api+json
And the following request fetches an article’s author:
GET /articles/1/author HTTP/1.1Accept: application/vnd.api+json
Responses
200 OK
A server MUST respond to a successful request to fetch an individual resource or resource collection with a 200 OK response.
A server MUST respond to a successful request to fetch a resource collection with an array of resource objects or an empty array ([]) as the response document’s primary data.
For example, a GET request to a collection of articles could return:
A server MUST respond to a successful request to fetch an individual resource with a resource object or null provided as the response document’s primary data.
null is only an appropriate response when the requested URL is one that might correspond to a single resource, but doesn’t currently.
Note: Consider, for example, a request to fetch a to-one related resource link. This request would respond with null when the relationship is empty (such that the link is corresponding to no resources) but with the single related resource’s resource object otherwise.
For example, a GET request to an individual article could return:
A server MUST respond with 404 Not Found when processing a request to fetch a single resource that does not exist, except when the request warrants a 200 OK response with null as the primary data (as described above).
Other Responses
A server MAY respond with other HTTP status codes.
A server MAY include error details with error responses.
A server MUST prepare responses, and a client MUST interpret responses, in accordance with HTTP semantics.
The text was updated successfully, but these errors were encountered:
Fetching Data
Data, including resources and relationships, can be fetched by sending a GET request to an endpoint.
Responses can be further refined with the optional features described below.
Fetching Resources
A server MUST support fetching resource data for every URL provided as:
a self link as part of the top-level links object
a self link as part of a resource-level links object
a related link as part of a relationship-level links object
For example, the following request fetches a collection of articles:
The following request fetches an article:
And the following request fetches an article’s author:
Responses
200 OK
A server MUST respond to a successful request to fetch an individual resource or resource collection with a 200 OK response.
A server MUST respond to a successful request to fetch a resource collection with an array of resource objects or an empty array ([]) as the response document’s primary data.
For example, a GET request to a collection of articles could return:
A similar response representing an empty collection would be:
A server MUST respond to a successful request to fetch an individual resource with a resource object or null provided as the response document’s primary data.
null is only an appropriate response when the requested URL is one that might correspond to a single resource, but doesn’t currently.
Note: Consider, for example, a request to fetch a to-one related resource link. This request would respond with null when the relationship is empty (such that the link is corresponding to no resources) but with the single related resource’s resource object otherwise.
For example, a GET request to an individual article could return:
If the above article’s author is missing, then a GET request to that related resource would return:
404 Not Found
A server MUST respond with 404 Not Found when processing a request to fetch a single resource that does not exist, except when the request warrants a 200 OK response with null as the primary data (as described above).
Other Responses
A server MAY respond with other HTTP status codes.
A server MAY include error details with error responses.
A server MUST prepare responses, and a client MUST interpret responses, in accordance with HTTP semantics.
The text was updated successfully, but these errors were encountered: