User Details
This document provides an in-depth guide to using the User Details API for the Firstock trading platform.
Overview
The User Details API allows authenticated clients to retrieve pertinent information about the currently logged-in user. This data can be used to display user profiles, identify enabled trading segments, or confirm user privileges.
Key benefits:
- Centralized Profile Data Retrieve user name, email, and exchanges in a single request.
- Security Ensures only valid session tokens can access user information.
- Integration Ready Quick check for user privileges (e.g., available order types, exchange permissions).
Endpoint & Method
POST
/userDetails
URL:
https://api.firstock.in/V1/userDetails
Headers
Name | Value |
---|---|
Content-Type |
application/json |
Body
Below is the general JSON body for the User Details API request. All fields marked as Mandatory must be included.
Field | Type | Mandatory | Description | Example |
---|---|---|---|---|
userId |
string |
Yes |
The same user ID |
AB1234 |
jKey |
string |
Yes |
Active session token obtained |
ce1c4471eb95... |
Request
{
"userId": "{{userId}}",
"jKey": "{{jKey}}"
}
Example cURL Request
curl --location 'https://api.firstock.in/V1/userDetails' \
--header 'Content-Type: application/json' \
--data '{
"userId": "{{userId}}",
"jKey": "{{jKey}}"
}'
Response Structure
Success Response
If the userId and jKey are valid, you will receive a 200 OK status with a JSON response containing:
- status: Typically "success".
- data: An object holding multiple user-related fields, such as account ID, email, enabled exchanges, and user privileges.
Key Fields:
- actid: The user’s account ID (often the same as userId).
- email: The user’s registered email address.
- exchange : An array indicating which exchanges the user can access.
- orarr : Supported order types (e.g., "MKT", "LMT", "SL-LMT", "SL-MKT").
- uprev: Current privilege level (e.g., "INVESTOR").
- requestTime : Timestamp for the request processing.
- userName : Full name of the user.
Failure Response
If your userId or jKey is missing, invalid, or expired, you may receive a 400 or 401 status code with error details:
- status: Typically "failed".
- code: Error code (e.g., "400", "401").
- name: A short label describing the error (e.g., "INVALID_JKEY").
- error: An object detailing the specific field error.
Response
{
"status": "success",
"data": {
"actid": "AB1234",
"email": "example@gmail.com",
"exchange": [
"NFO",
"NSE",
"BSE",
"BFO"
],
"orarr": [
"MKT",
"LMT",
"SL-LMT",
"SL-MKT"
],
"requestTime": "10:40:21 23-04-2025",
"uprev": "INVESTOR",
"userName": "DEMOFIRSTNAME DEMOMIDDLENAME DEMOKUMAR"
}
}
{
"status": "failed",
"code": "401",
"name": "INVALID_JKEY",
"error": {
"field": "jKey",
"message": "jKey parameter is invalid"
}
}
Usage & Best Practices
- Store Session Tokens Securely
- Make sure you’re using the correct jKey (or susertoken) from your most recent successful login.
- Check Exchange & Order Types
- The fields exchange and orarr can be used to conditionally display or enable features in your trading app. For instance, if NFO is not listed, you can hide or restrict derivatives trading.
- Error Handling
- If status is "failed" inspect the field and message in error to debug issues (e.g., invalid token, missing user ID).
- Session Expiry
- Tokens may expire after a certain duration. If you receive repeated INVALID_JKEY errors, prompt the user to log in again.
- Minimal Permissions
- Tokens may expire after a certain duration. If you receive repeated INVALID_JKEY errors, prompt the user to log in again.
Conclusion
The User Details API is essential for any application needing real-time profile and account data for a logged-in user. By validating the correct jKey and userId, you can seamlessly fetch exchanges, order types, and user privilege levels to tailor the user’s trading experience. For further troubleshooting or more in-depth functionality, refer to Firstock’s official documentation or contact support.