Exception & 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. |
SESSION_EXPIRED | Represents user account related errors. |
INVALID_[variable] | Represents when a variable is invalid, depending on the variable type in the request response. |
ORDER_NOT_FOUND | Represents when an order is 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 is not enabled on exchange NSE. |
BASKET_DETAILS | Represents when a basket should contain orders of only one exchange. |
EXCHANGE/TOKEN | Represents when no data is available on the token or exchange. |
API_RATE_LIMIT | Represents when users exceed the rate limit. |
Common HTTP error codes
Code | Description |
---|---|
200 | OK - The request has succeeded |
201 | Created - The request has been fulfilled and resulted in a new resource being created |
202 | Accepted - The request has been accepted for processing, but the processing has not been completed |
204 | No Content - The server successfully processed the request, but is not returning any content |
207 | Multi-Status status code provides status for multiple independent processes |
301 | Moved Permanently - The requested resource has been assigned a new permanent URI |
302 | Found - The requested resource resides temporarily under a different URI |
304 | Not Modified - Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match |
307 | Temporary Redirect - The requested resource resides temporarily under a different URI |
308 | Permanent Redirect - The request, and all future requests should be repeated using another URI |
400 | Bad Request - The request could not be understood by the server due to malformed syntax |
401 | Unauthorized - The request requires user authentication |
403 | Forbidden - The server understood the request, but is refusing to fulfill it |
404 | Not Found - The server has not found anything matching the Request-URI |
405 | Method Not Allowed - The method specified in the Request-Line is not allowed for the resource identified by the Request-URI |
406 | Not Acceptable - The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request |
408 | Request Timeout - The client did not produce a request within the time that the server was prepared to wait |
409 | Conflict - The request could not be completed due to a conflict with the current state of the resource |
410 | Gone - The requested resource is no longer available at the server and no forwarding address is known |
411 | Length Required - The server refuses to accept the request without a defined Content- Length |
413 | Payload Too Large - The server is refusing to process a request because the request entity is larger than the server is willing or able to process |
414 | URI Too Long - The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret |
415 | Unsupported Media Type - The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method |
429 | Too Many Requests - The user has sent too many requests in a given amount of time ("rate limiting") |
500 | Internal Server Error - The server encountered an unexpected condition which prevented it from fulfilling the request |
501 | Not Implemented - The server does not support the functionality required to fulfill the request |
503 | Service Unavailable - The server is currently unable to handle the request due to a temporary overloading or maintenance of the server |
504 | Gateway Timeout - The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server or some other auxiliary server it needed to access in order to complete the request |
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.
Endpoint | Rate-Limit |
---|---|
Quote | 4 req/second |
Historical Candle | 3 req/second |
All other endpoints | 10 req/second |
Order Placement | 200 req/minute |