Request And Response

Generally speaking, all requests originate with you; in other words, you contact the API. The API does not contact you.


The API design incorporates REST principles. More specifically, each request is an HTTP request directed to an endpoint and each endpoint corresponds to a resource. All of the needed parameters are included in the URL as parameters and the API then returns the information you seek.

Some methods require data for input; others have no output.

Requests


As we have seen, all methods are called via HTTP. Some via GET and some via POST.

curl -X [GET|POST] -H "Authorization: Basic {Token}" "https://oms.sokochan.com/api/1.0/products"

Responses


The response format for all requests is a JSON object.
Whether a request succeeded is indicated by the HTTP status code. A 2xx status code indicates success, whereas a 4xx status code indicates failure. When a request fails, the response body is still JSON, but always contains the fields code and error which you can inspect to use for debugging.

{"SokochanCode":"00100001","SKU":"282078_0","Number":"OLT001","InStock":11,"Available":8,"OnOrder":3}
{
  "code": 404,
  "error": "Product not found"
}

Standard Response Codes

The Order API uses standard HTTP response codes to indicate success or error.

Code Description
200 OK Success.
404 Not Found Order not found.
400 Bad RequestWrong URL parameters.
405 Method Not Allowed Incorrect HTTP method (GET instead of POST, for example)
500 Internal Server Error Something is wrong on our server.
403 Forbidden API account does not allow this kind of requests.