Documentation
HomeGithubDiscordBlog
  • What is OpenAlgo?
  • OpenAlgo Architecture
  • Mini FOSS Universe
  • Community Support
  • OpenAlgo GPT
  • New Features
    • Fast Scalper
    • API Analyzer
    • Traffic/Latency Monitor
    • Chartink Integration
  • Monetization
  • Connect Brokers
    • Brokers
      • 5Paisa
      • 5paisa (XTS)
      • AliceBlue
      • AngelOne
      • Compositedge
      • Dhan
      • Dhan(Sandbox)
      • Firstock
      • FlatTrade
      • Fyers
      • Groww
      • IIFL (XTS)
      • Jainam Retail (XTS)
      • Jainam Dealer (XTS)
      • Kotak Securities
      • Paytm
      • Pocketful
      • Shoonya
      • Tradejini
      • Upstox
      • Wisdom Capital
      • Zebu
      • Zerodha
  • Installation Guidelines
  • Getting Started
    • Windows Installation
      • Pre-Requesites
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • SSL Verification Failed
      • Accessing OpenAlgo
    • Windows Server Installation
    • Mac OS Installation
      • Pre-Requesties
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • Install certifi
      • Accessing OpenAlgo
    • Amazon Elastic Beanstalk
    • Ubuntu Server Installation
    • Docker Development
    • Testing OpenAlgo in Cloud
    • Upgrade
  • Latency
  • API Documentation
    • V1
      • Accounts API
        • Funds
        • Orderbook
        • Tradebook
        • PositionBook
        • Holdings
      • Orders API
        • Placeorder
        • PlaceSmartOrder
        • BasketOrder
        • SplitOrder
        • ModifyOrder
        • CancelOrder
        • CancelAllOrder
        • ClosePosition
        • OrderStatus
        • OpenPosition
      • Data API
        • Quotes
        • Depth
        • History
        • Intervals
        • Symbol
        • Ticker
      • Websockets
      • Order Constants
      • HTTP Status Codes
      • Rate Limiting
      • API Collections
  • Symbol Format
  • MCP
  • Trading Platform
    • Amibroker
      • AmiQuotes
      • Button Trading Module
      • Button Trading with Split Orders
      • Button Trading with Stoploss
      • SmartOrder Chart Module
      • Trailing Stoploss Execution Module
      • Line Trading Module
      • Equity Exploration Module
      • CSV Exploration Module
      • Options Button Trading Module
      • Spot/Futures to Options Module (Single Leg)
      • Spot/Futures to Options Module (Two Leg)
      • Time Based Execution
    • Tradingview
      • Futures to Options Module
    • ChartInk
    • Python
      • Strategy Management
      • EMA Crossover Strategy
      • EMA Crossover Strategy with Stoploss and Target
      • Supertrend Strategy
      • Supertrend Strategy with yfinance data
      • Voice Based Orders
    • NodeJS
    • Metatrader 5
      • Download & Install Library
      • OpenAlgo MQL5 Functions
      • Include the Header File
      • Sample Expert Advisor
    • Excel
    • Google Spreadsheets
    • N8N
    • Chrome Extension
  • Strategy Management
  • Developers
    • Design Documentation
      • Architecture
      • API Layer
      • Broker Integerations
      • Database Layer
      • Authentication Platforms
      • Configuration
      • Utilities
      • Broker Integration Checklist
  • Change Log
    • Version 1.0.0.25 Launched
    • Version 1.0.0.24 Launched
    • Version 1.0.0.23 Launched
    • Version 1.0.0.22 Launched
    • Version 1.0.0.21 Launched
    • Version 1.0.0.20 Launched
    • Version 1.0.0.19 Launched
    • Version 1.0.0.18 Launched
    • Version 1.0.0.17 Launched
    • Version 1.0.0.16 Launched
    • Version 1.0.0.15 Launched
    • Version 1.0.0.14 Launched
    • Version 1.0.0.13 Launched
    • Version 1.0.0.12 Launched
    • Version 1.0.0.11 Launched
    • Version 1.0.0.10 Launched
    • Version 1.0.0.9 Launched
    • Version 1.0.0.8 Launched
    • Version 1.0.0.7 Launched
    • Version 1.0.0.6 Launched
    • Version 1.0.0.5 Launched
    • Version 1.0.0.4 Launched
    • Version 1.0.0.3 Launched
    • Version 1.0.0.2 Launched
    • Version 1.0.0.1 Launched
    • Version 1.0.0.0 Launched
Powered by GitBook
On this page
  1. Connect Brokers
  2. Brokers

Dhan(Sandbox)

PreviousDhanNextFirstock

Last updated 18 days ago

What is Dhan SandBox API?

Dhan SandBox API is a simulated testing environment designed for developers and traders to experiment with Dhan’s trading and market data APIs without needing a live brokerage account or actual capital. It replicates the real trading environment but ensures zero risk by not executing trades on the actual exchange. It is ideal for testing integrations, validating order logic, and experimenting with strategies.


Who Should Integrate Dhan SandBox API with OpenAlgo?

OpenAlgo is an open-source algo trading automation framework that connects with platforms like TradingView, Amibroker, and custom dashboards. Integrating Dhan’s SandBox API with OpenAlgo is highly recommended for:

  • Algo Developers building broker connectors.

  • Traders who want to simulate real-time automated strategies before going live.

  • Educators and Trainers who want a safe demo environment.

  • Early-stage Fintech Builders exploring trading APIs.

  • QA and Support Teams needing to replicate live bugs or behaviors in a controlled setup.


Step-by-Step: How to Get Started with Dhan SandBox API

Here’s how to register, access tokens, and start testing with OpenAlgo:

1. Visit DhanHQ DevPortal

You’ll land on a login screen where you can enter your email or mobile number.


2. Register (if new)

If you’re a new user, click to register. Provide:

  • Email ID

  • Mobile Number

  • Your Name

Proceed to the next step.


3. OTP Verification

You will receive two OTPs:

  • One on your email

  • One on your mobile

Enter both to complete verification.


4. Access Your Sandbox Token and Client ID

Once inside, go to the Sandbox tab. You’ll see:

  • Application Name (e.g., openalgo)

  • Access Token (JWT for authorization)

  • Client ID (unique to your application)

  • API Playground and documentation links

These credentials are what you will use inside OpenAlgo’s configuration or .env file to test trading orders programmatically.


Retrieve API Credentials

Once you've successfully logged into the DhanHQ DevPortal and created your sandbox application:

  1. Copy the Client ID

    • This is your BROKER_API_KEY

    • It uniquely identifies your application (e.g., 2505178942)

  2. Copy the Access Token

    • This is your BROKER_API_SECRET

It acts like a password (JWT format) to authenticate your API requests.

Configuration for OpenAlgo

Inside your OpenAlgo project (or any backend using Dhan APIs), create or update the .env file with the following keys:

BROKER_API_KEY = 'your_dhan_sandbox_clientid_here' 
BROKER_API_SECRET = 'your_dhan_sandbox_token_here' 
REDIRECT_URL = 'http://127.0.0.1:5000/dhan_sandbox/callback'

Summary: Why It Matters for OpenAlgo

Integrating Dhan SandBox with OpenAlgo means:

  • Safer testing for order placement, cancellation, and position handling.

  • No compliance delay since no KYC is needed.

  • Faster debugging and integration turnaround.

  • Enables workshops, testing, and community support for algo development.

By setting up your sandbox environment with Dhan and OpenAlgo, you accelerate your readiness for live algorithmic trading while ensuring a risk-free development experience.