User APIs¶
This section covers endpoints for retrieving user-specific information like account profile and funds.
| Request Type | Path | Description |
|---|---|---|
| GET | /user/profile | Get the profile information for the logged-in user. |
| GET | /funds | Fetches the user's available and utilized funds. |
| POST | /generate/token | Generate an access token via TOTP. |
Getting Your Access Token¶
There are two ways to get the access_token used in the Authorization header on every request.
Method 1: Dashboard token generation¶
Individual traders can directly get their Access Token from web.indstocks.com. All INDstocks users are eligible to get free access to Trading APIs. Here's how to get your Access Token:
- Log in to indstocks.com
- Go to indstocks.com/app/api-trading/access-tokens and generate your access token.
Method 2: TOTP-based token generation¶
For server-side / headless integrations, you can generate an access token using a TOTP (Time-based One-Time Password) instead of logging into the dashboard each time.
Setup (one-time)
- Log in to indstocks.com and go to indstocks.com/app/api-trading/access-tokens — the same page where you generate your dashboard access token and set up your Static IP.
- Click Setup TOTP and follow the steps to link an authenticator app. Scan the QR code (or enter the key manually), then submit one code from the app to confirm.
- Once TOTP setup succeeds, the page displays your Client ID — this is the static
x-api-keyvalue for your account, used in place of theAuthorizationheader for this endpoint only. - You can now generate a fresh access token at any time by calling the endpoint below instead of returning to the dashboard.
Setup constraints
- You have 5 minutes to complete setup once the secret and QR code are displayed. If you don't submit a confirming code in that window, the pending secret is discarded and you start over. Closing the browser mid-setup has the same effect — TOTP only becomes active after a successful confirmation code.
- The secret is shown exactly once and is never retrievable afterwards. Store it in your authenticator app (and, if you need a backup, your own secrets manager) before leaving the page. If you lose it, you must disable TOTP and re-enroll to get a new secret.
- Setup is web-only. There is no API to enable, reset, or read the TOTP secret — it requires a logged-in session on the website. Only token generation is available over the API.
Endpoint
Headers
| Header | Required | Description |
|---|---|---|
x-api-key | ✅ | Your Client ID — a static identifier for your account, shown on the dashboard after successful TOTP setup. Distinct from access_token; not sent as Authorization. |
Content-Type | ✅ | application/json |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
mpin | string | ✅ | Your INDstocks account MPIN. |
totp | string | ✅ | The current 6-digit code from your authenticator app. |
Example Request
curl --location 'https://api.indstocks.com/generate/token' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"mpin": "YOUR_MPIN",
"totp": "123456"
}'
Response Payload (Success)
The response returns the access token in a field named token (not access_token). Use its value in the Authorization header of every other request, same as the dashboard-generated token.
Token lifecycle
Only one TOTP-generated token is live at a time. Each successful call to /generate/token invalidates the token issued by the previous call. There is no way to hold two valid TOTP tokens concurrently.
The practical consequences:
- Generate your token once per session and reuse it for the rest of the day. Don't call
/generate/tokenbefore each request — you'll invalidate the token your other processes are using. - If you run multiple processes or machines, have one of them generate the token and share it with the others. Two processes each generating their own token will keep killing each other's.
- A token remains valid for 24 hours from generation, unless it's replaced by a newer one, revoked from the dashboard, or invalidated by disabling TOTP.
- The currently-live token is displayed on the dashboard next to your Client ID, with an option to revoke it. Revoking takes effect immediately — in-flight and subsequent calls with that token will fail with
TokenException.
TOTP limits and lockouts
| Rule | Limit | Notes |
|---|---|---|
| Minimum gap between token generations | 1 token per 60 seconds | A token lasts 24 hours, so a correctly-written client never needs another this soon. This exists to stop a looping script. |
| Wrong TOTP codes before lockout | 5 failed attempts → 15-minute lockout | Applies to the totp field specifically. |
| Window for counting failed attempts | Rolling 15 minutes | Isolated typos hours apart don't accumulate into a lockout. |
| Repeated lockouts | 3 lockouts within 1 hour → 1-hour lockout | Also triggers an email alert to the account holder. If you hit this without knowing why, contact api-support@indstocks.com. |
| Attempts while already locked out | Rejected, and do not extend the lockout | A client that keeps retrying during a lockout won't lock itself out indefinitely — but you should still back off. |
A lockout does not kill your existing access token
Being locked out blocks new token generation only. An access token that was already issued keeps working until its normal 24-hour expiry. This is deliberate: a lockout is usually a misconfigured or clock-skewed client, and revoking a live token would strand a running strategy with open positions. If you believe your credentials are actually compromised, revoke the token from the dashboard rather than waiting for the lockout to clear.
These numbers are the launch values and may be tuned once we see real traffic. Build your client to read the error response rather than hard-coding these thresholds, and always back off on failure instead of retrying immediately.
Failure cases
| Scenario | Result | What to do |
|---|---|---|
Wrong mpin | Rejected. | Fix the MPIN. Don't retry with the same value. |
Wrong or expired totp | Rejected, and the attempt is counted toward the 5-attempt lockout. | Wait for the next code from your authenticator app — don't retry the same code. |
| Called again within 60 seconds of a successful generation | Rejected by the throttle. | Cache and reuse the token you already have; see Token lifecycle. |
| Locked out (5 wrong codes, or 3 lockouts in an hour) | Rejected for 15 minutes / 1 hour. | Back off for the full window. Check your server clock before trying again. |
| Server clock drift | Small drift is tolerated; large drift causes every code to fail. | Fix it on your side — sync via NTP. A host whose clock has drifted by more than about a minute will fail every attempt while showing a "valid" code in the app. |
| TOTP disabled from the dashboard | The secret is deleted and the active token is revoked immediately. | Re-run setup to get a new secret, then generate a fresh token. |
| Using a token that was replaced or revoked | Calls fail with TokenException (403). | Generate a new token. If this happens unexpectedly, check whether another process is also calling /generate/token. |
Lost your authenticator device?
There is no way to recover or re-display an existing secret. Log in to the website, choose Disable TOTP, then run setup again for a fresh secret. If you can't log in to the website at all, use the standard forgot-password / account-unlock flow, or contact api-support@indstocks.com for a support-assisted disable.
User Profile¶
Retrieves the profile information for the authenticated user. This is a useful endpoint to test if your access token is valid.
Endpoint
Example Request
curl --location 'https://api.indstocks.com/user/profile' \
--header 'Authorization: YOUR_ACCESS_TOKEN'
Response Payload (Success)
{
"status": "success",
"data": {
"user_id": "1234567",
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"demat_id": "",
"is_nse_onboarded": true,
"is_bse_onboarded": true,
"is_nse_fno_onboarded": true,
"is_bse_fno_onboarded": true,
"ucc": "1ABCDE2N7X",
"is_ddpi_active": true
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
ucc | string | Unique Client Code — the exchange-assigned client identifier. |
is_ddpi_active | boolean | Whether Demat Debit and Pledge Instruction (DDPI) is active for this account, allowing delivery sells without a separate CDSL TPIN authorization. |
Get Funds¶
Retrieves the funds utilization and availability for the authenticated user.
Endpoint
Example Request
Response Payload (Success)
{
"status": "success",
"data": {
"sod_balance": 4996.47,
"pledge_received": 0,
"pledge_remained": 0,
"detailed_avl_balance": {
"option_sell": 2980.40,
"future": 2980.40,
"option_buy": 4449.65,
"comm_option_buy": 2980.40,
"eq_mis": 2980.40,
"eq_cnc": 2980.40,
"eq_mtf": 2980.40
},
"withdrawal_balance": 2983.47,
"funds_added": 0,
"funds_withdrawn": 0,
"realized_pnl": -751.92,
"unrealized_pnl": 62.15,
"brokerage": 0,
"eq_charges": 0,
"fno_charges": 0
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
detailed_avl_balance.comm_option_buy | number | Available balance for commodity option buying. |
brokerage | number | Brokerage accrued for the day. |
eq_charges | number | Equity segment charges accrued for the day. |
fno_charges | number | F&O segment charges accrued for the day. |
See Also¶
- API Conventions — request/response format and rate limits
- Glossary & Constants — TOTP fields, ID prefixes, shared enums
- Error Bucket —
TokenExceptionand other auth-related errors