This page describes the API features that should be standardized across every microservices. Abiding to these conventions is in most cases a requirement, so stick to it!
There are 2 3 parts which are standardized: The format of the request, the format of the response and the format of the url URL of the API endpoint, both all three have their own section on this page.
As a general tip: use your browser's network tracking developer tools to inspect the behavior of what already is!
Table of Contents | ||||
---|---|---|---|---|
|
General API requirements
Each microservice's API should return the data in the same way, defined below:
...
Nico Should propose a format here
Request API requirements
...
A request should be a standard HTTP request to one of the endpoints of the microservice as defined by its API. The request should use one of the specified HTTP methods (for example: GET, POST, DELETE, etc.). In addition to this the header 'X-Auth-Token' is required to be (correctly) set for most endpoints.
Getting an X-Auth-Token
There are several ways to obtain an X-Auth-Token:
- For a microservice you should follow this protocol.
- As a user you can request your access token from the http://localhost/api/login endpoint.
- Use the POST method, no headers special headers are required.
- Body:
- username: 'flaviu@glitch.ro'
- password: '1234'
Response API requirements
...
The response structures for the successful and unsuccessful request are slightly different.
Successful response
Code Block | ||
---|---|---|
| ||
{ "success": true, "meta": {}, "data": [], "message": "A message to user." } |
...
In the response, either the 'data' or 'message' fields should be presented.
Unsuccessful response
Code Block | ||
---|---|---|
| ||
{ "success": false, "errors": [], "message": "An error has occured." } |
...