Exceptions & error
Find more about the common errors, exceptions, HTTP error codes and API Rate Limit.
The Firstock Connect error response consists of the "status" key indicates the overall status of the request, with a value of "Failed" indicating that the request was not successful. The "code" key provides a more specific error code, in this case an HTTP status code will be provided. The "name" key provides an additional error code that is specific to the API being used.
The "error" key provides further information about the error, including the field that caused the problem ("field" key with a value of the request response) and a description of the problem ("message" key with a value of the error).
Failed request
HTTP/1.1 500 Server error
Content-Type: application/json
{
"status": "Failed",
"code": "401",
"name": "INVALID_USERID",
"error": {
"field": "userid",
"message": "userid parameter is invalid"
}
}
Exceptions
Value | Description |
---|---|
BAD_REQUEST | Undefined or missing parameter in the request structure provides this exception. |
SESSION_EXPIRED | Represents user account related errors |
INVALID_[variable] | Represents when variables is invalid, depends on the variable type in request response. |
ORDER_NOT_FOUND | Represents when Order not found to cancel |
ORDERS_NOT_FOUND | Represents when No data on the orders was found |
PRODUCT_CONVERSION | Represents when Product Conversions are disallowed after system square off |
PRODUCT_USAGE | Represents when Product Regular not enabled on exchange NSE |
BASKET_DETAILS | Represents when Basket should contain orders of only 1 exch |
EXCHANGE/TOKEN | Represents when no data is available on the token or exchange |
API_RATE_LIMIT | Represents when the users exceed the rate limit. |
Common HTTP error codes
Codes | Description |
---|---|
400 | Missing or bad request parameters or values |
401 | Session expired or invalid input |
404 | Request resource was not found |
405 | Request method (GET, POST etc.) is not allowed on the requested endpoint |
410 | Request resource is lost |
429 | Too many requests to the API (rate limiting) |
500 | Something unexpected went wrong |
503 | Service is unavailable |
504 | Gateway timeout; the API is unreachable |
API Rate Limit
At Firstock, in an effort to manage potential risks, the request rate for APIs has been limited based on different segments. The following table provides information on the rate limits for various APIs.
End Point | Rate-Limit |
---|---|
Quote | 4 req/second |
Historical Candle | 3 req/second |
All other endpoints | 10 req/second |
Order Placement | 200 req/minute |