As mentioned on API Authentication page, all the requests must have some form of header to fulfill a request. The following document explains the request and response formats used by EvenCart API.
Request Format
EvenCart has specific requirements for sending requests to the app. The requests must conform to these rules for API calls to work correctly.
- For POSTs requests, the Content-Type header must be set to
application/x-www-form-urlencoded
. - For GET requests, the parameters should be sent as query string parameters appended to the endpoint URLs.
- The method should only be GET and POST. No other methods are support. For CORS, OPTIONS method is supported.
- For end points which don't require authentication, the header
X-API-VERIFICATION
must be sent with each request. The header is not required in case the user's bearer token is being sent.
Response Format
All the responses in the EvenCart API are JSON with response content type set to application/json
. All the responses follow a common JSON structure.
{
"success": true,
"context":"name of context",
"error": "only if success is false"
...
}
As seen from the example above, all the responses will include a success
key set to either true
or false
.
The value indicates if the request succeeded or not. A context
key in the response indicates the context name for the request. An optional error
key is included in the response, in case success
is false.
Note: You should not rely solely on
success
value to check if the request was successful or not. Always rely on HTTP Status code in addition to make sure that request was successful. A200
response code will ensure that the request was successful. Note however thatsuccess
may be false for a200
response, thus you should read theerror
key to know the reason for failure.
In addition to the above mentioned keys, each response may contain additional keys depending on the endpoint.
Next Steps
Congratulations! Now that you've understood about the API authentication and usage, you can start consuming the API endpoints and create some awesome apps.