Acuris REST API Guidelines

Guideline for creating RESTful APIs at Acuris, in order to drive consistency between our APIs.

Table of Contents

Principles

General Guidelines

$ curl http://api.example.com/v1/reviews/269

[
  {
    "country": "Argentina",
    "province": "Mendoza Province",
    "variety": "Cabernet Sauvignon",
    "kind": "review",
    "price": "15.0",
    "geography": "Argentina#Mendoza Province#Agrelo#",
    "description": "Immediately this smells raisiny, but with time secondary scents of cinnamon and Middle Eastern spices come into play. The body is soft and extracted, with modest acidity. Flavors of baked black fruits, fig paste, chocolate and herbs follow the nose, as does a chocolaty, rich  finish. Drink through 2016.",
    "id": "269",
    "designation": "Single Vineyard Reserva",
    "winery": "Lamadrid",
    "region": "Agrelo",
    "points": "88"
  }
]
 $ curl -i http://api.example.com/resources?unknownParam=true

 HTTP/1.1 400 Bad Request

{
   "message":"There were unknown parameters in the request \"unknownParam\"",
   "validParams":[
      "after",
      "before",
      "size",
      "countries",
      "q",
      "fields",
      "sort"
   ]
}

Query, Sorting and Pagination

Errors

$ curl -i http://api.example.com/error
HTTP/1.1 504 Internal Server Error

{
    "error": {
        "code":"ISS-12",
        "message": "An error was received from the database, please try again later"
    }
}

Common Query Parameters

Where possible, stick to common conventions for query parameter names as follows:

Parameter Name Description
mmgid the ID of a resource in the Prime database. Ensure that it is structured as <source>-<id-within-source> e.g prime-1234 or docrepo-10201
fields if allowing the client to specify a subset of fields to be returned
sort to allow the ordering of returned results. For specific ordering use + for ascending and - for descending
before and after if using cursoring, provide the previous and next cursor values. Where after is a pointer to the last resource in the current page and before is a pointer to the first resource in the current page.
offset if using pagination, provide the offset of the first item and use in conjunction with size to provide the number of items per page
size the number of items returned in the response

Performance and Cacheability

Versioning

Common consistencies