How to use

Quick reference for tokens, intervals, CSV format, and common errors.

1. Generate a Dhan access token
From your Dhan account, top-right → My Profile → DhanHQ Trading APIs → Access Token.
  1. Log in to web.dhan.co.
  2. Go to Profile → DhanHQ Trading APIs.
  3. Generate a new access token (valid for ~24 hours).
  4. Copy it and paste into the token field in the header. Optionally add your Client ID.
  5. Click Verify — the pill turns green when the token works.
2. Intervals & date windows

Intraday intervals: 1, 5, 15, 25, 60 minutes. Daily: D.

Intraday history is limited to ~90 days per request — long ranges are auto-chunked and stitched. Daily history covers a longer window in one call.

3. CSV schema
timestamp,datetime_ist,date,open,high,low,close,volume,open_interest

Timestamps are Unix seconds. datetime_ist is for human reading; date is ISO 8601.

4. Troubleshooting
ErrorLikely cause / fix
401Token expired or wrong. Regenerate it in Dhan dashboard.
429Rate-limited. Engine auto-retries; increase delay (ms) if it persists.
EmptyNo data — check trading days; expired contract may not cover the range.
No contractClick Refresh on the instrument master.
CORSDefault proxy mode avoids it — only happens if you switch to direct mode.