Skip to content

Api Common Parameters

Carlos Badenes edited this page Mar 31, 2016 · 1 revision

Filtering

Every field of a resource can be used as filter by the relational operator =. Numeric values also admit > and <.

GET /documents?words.size>100

This returns the list of documents with more than 100 words.

Every resource can be filtered by other resource (singular and lower-case) as related, so:

GET /documents?domain=1488437

will return the list of documents in the domain with uri: domains/1488437.

Sorting

Allows ascending and descending sorting over multiple fields

GET /documents?sort=-title,+published

This returns a list of documents sorted by descending titles and ascending publication dates.

Field Selection

Maybe you need more attributes than default. Using the fields parameter you can choose among all available fields of the resource:

GET /documents?fields=title,creators,published,uri

Also, every resource can include other related resource by adding the name of the resource (singular and lower-case):

GET /documents/34234235?fields=title,domain

This return the title of the document and the list of domains where it is contained.

Paging

  • offset: specific page to be returned. Default is 0.
  • limit: max number of resources by page. Default is 20.
GET /documents?offset=2&limit=20

The number of total entries is sent in the X-Total-Count HTTP header.
Links to the next or previous page are provided in the HTTP header link:

Link: <http://../documents?offset=2&limit=10>; rel="next",<http://../documents?offset=20&limit=10>; rel="last"

Errors

System uses HTTP Standard codes and the exact error is explained in the error payload:

  • 400 - Bad Request: The request was invalid or cannot be served
{
  "message": "Parameter: 'xxxx' does not exist",
  "code": 34,
  "moreInfo": "http://.../errors/34"
}
Clone this wiki locally