All responses from WCEA API come with an envelope, which contains meta information, such as Status
and Count
.
In the case of responses that contain a list, the metadata also contains pagination hints indicating where we are on the list and how many items are still left etc.
The metadata object also contains a links
sub-object, which contains HATEOAS links related to the current resource.
For list type responses, pagination links are provided as a convenience allowing you to jump from page to page, as well as links to the first and last pages where appropriate.
For responses that contain a single resource, any related resource urls are also available as HATEOAS links inside the metadata links
object.
Metadata Properties
status | Either SUCCESS or ERROR depending on whether there was an error |
||||
---|---|---|---|---|---|
count | total number of items returned in this response | ||||
offset | only shows up on list type resources, contains the current data offset | ||||
total | only shows up on list type resources, contains the total number of items in the list | ||||
links |
sub-object containing links either to related resources, or pagination links. The key for each link contains the relation from the current resource to the linked resource:
|
Metadata contained in the response can be accessed using a special getter method, this method is available after every request made to the API, and contains metadata from the last request performed.
$API->getUser(1234); $metadata = $API->getMetadata();print_r($metadata);
---- OUTPUTS ----
array( "status" => "SUCCESS", //HTTP Code "count" => 10, //number of items in the response //other items "links" => array() //HATEOAS links )
HATEOAS links can be accessed on their own instead of getting the whole metadata object by using special getter getLinks()
:
$API->getUser(1234); $links = $API->getLinks();print_r($links);
---- OUTPUTS ----
array( "e-learningPofile" => array( "method" => "GET", "uri" => "/v1.1/user/1234/elearningProfile" ) )