Skip to Main Content

Prerequisites

Everything you need in place — account, credentials, environment, compliance, and security — before making your first API call.

Overview

This page is a complete pre-integration checklist. Skipping any one of these categories is the single biggest source of "the API doesn't work" support tickets — most turn out to be setup gaps (unenabled API access, unsynced TOTP clock, missing Algo ID tagging) rather than actual API issues. Work through each section before you write your first line of integration code.

1. Account & Access Prerequisites

RequirementDetails
Active Shoonya trading accountFully KYC-verified. Your uid (client ID) is tied to this account and appears in every request body.
API access explicitly enabledOpt-in, separate from having a trading account. Confirm this in account settings — a disabled flag here produces a login failure that looks identical to a credentials error.
Segment-level exchange enablementNSE, NFO, BSE, MCX, CDS are enabled independently. A SearchScrip or PlaceOrder call against a segment you're not enabled for fails even with valid credentials — check this before assuming a code bug.
Sufficient account funding/marginNot an API concern directly, but order-placement testing against a zero-margin account returns rejection responses that are easy to misdiagnose as an API integration error.

2. Authentication Prerequisites

RequirementDetails
TOTP 2FA configuredMandatory for both manual and automated login. See TOTP Setup Guide.
TOTP secret stored securelyNeeded to generate OTPs programmatically for Auto Login. Treat it as a credential, not a config value.
System clock synced (NTP)TOTP is time-based — a server clock drifted by more than ~30s produces intermittent, hard-to-reproduce login failures. Verify NTP sync on any server running automated login, especially cloud VMs.
Understanding of session lifecycleRead Login Flow Overview and Token Renewal — know when your AccessToken expires and how renewal works before building anything that runs unattended overnight.
Vendor/App credentials (if applicable)Only if integrating as a registered vendor rather than a single account holder. See For Vendors / Partners.

3. Technical / Environment Prerequisites

ItemNotes
HTTPS-capable HTTP clientAll REST endpoints are HTTPS-only, form-urlencoded (jData/jKey) — see API Structure before assuming raw JSON bodies work.
Python SDK (recommended)NorenRestApiPy wraps auth, order, quote, and search calls. See Python SDK.
WebSocket client libraryRequired only for live feeds (order updates, market data). See WebSocket Overview. Not needed for REST-only, poll-based integrations.
Reconnect/retry handling capabilityWebSocket connections drop — plan reconnect logic (exponential backoff, resubscribe-on-reconnect) as a first-class design concern, not an afterthought bolted on after production issues surface.
Reliable outbound network pathIf running on a corporate network or restrictive cloud VPC, confirm outbound HTTPS/WSS to api.shoonya.com isn't blocked by firewall/proxy rules before debugging "connection refused" as an SDK issue.
Logging in placeStructured logging (request payload, response, latency) from day one — this is what actually lets you tell "no data" (normal) apart from "session expired" (needs re-auth) apart from "network failure" (needs retry) at 2am when something breaks unattended.

4. Security Prerequisites

ItemNotes
Secrets managementEnv vars, a secrets manager, or encrypted config — never commit uid, password, or TOTP secret to source control, including private repos.
AccessToken handlingStore tokens encrypted at rest if persisted between runs. Treat a leaked AccessToken as equivalent to a leaked password — it grants full account access until it expires or is invalidated.
IP allowlisting awareness (if enforced on your account)Some account configurations restrict API calls to specific IPs. If you plan to run from a dynamic-IP environment (e.g. home broadband, ephemeral cloud instances), confirm this isn't enabled or plan for a static egress IP.
Least-privilege deploymentIf multiple services touch the same account (e.g. a quote poller and a separate order engine), consider whether they need to share one token/session or should be isolated — a bug in one shouldn't be able to silently place orders via the other.

5. Compliance Prerequisites (if running an algo)

If you're building an automated/algorithmic strategy — as opposed to a manual-trigger tool a human approves before each order — read SEBI Algo ID Framework before writing any order-placement code.

  • Determine whether your strategy is white-box or black-box under SEBI's Feb 2025 circular — this determines your disclosure obligations.
  • Confirm NNF ID / Algo ID tagging requirements and build them into your order payload structure from the start — retrofitting tagging after orders are already flowing is significantly more error-prone than designing for it up front.
  • If distributing your strategy to other users (vendor model), confirm empanelment status and NDA terms are in place before onboarding external clients.
  • Track the enforcement deadline for your compliance category — see SEBI Algo ID Framework for current dates.

6. Operational Readiness

ItemWhy it matters
Rate limit awarenessReview Rate Limits before designing polling logic. Code that works fine in light testing can silently start failing near production load if it wasn't designed against the actual limits.
Error handling strategyRead Error Handling — know the difference between a retryable error (session expired, transient network) and a non-retryable one (invalid input, insufficient margin) before your retry logic accidentally loops on something it can never fix.
Idempotency plan for order placementNetwork retries on a timed-out PlaceOrder call can result in duplicate orders if you don't have a way to check "did this actually go through" before retrying.
Monitoring / alertingFor anything running unattended (algo strategies, scheduled quote pollers), have alerting on auth failures and WebSocket disconnects — silent failure in a trading system is worse than a loud one.

Pre-flight Checklist

  • Shoonya trading account active, KYC complete, sufficiently funded
  • API access enabled on the account
  • Required exchange segments enabled (NSE/NFO/BSE/MCX/CDS as needed)
  • TOTP 2FA configured, secret stored securely, server clock NTP-synced
  • Read Authentication Overview and Token Renewal
  • HTTP client / SDK chosen and installed
  • Reconnect/retry strategy planned for WebSocket use (if applicable)
  • Secrets management in place — no credentials in source control
  • Read Rate Limits and Error Handling
  • Idempotency plan for order placement retries
  • If running an algo: reviewed SEBI Algo ID Framework, Algo ID tagging designed in
  • Monitoring/alerting plan for unattended processes

Notes

Treat this list as gating, not optional — most production incidents in trading integrations trace back to one of these being skipped rather than a defect in the API itself. Once every box is checked, continue to Quick Start (5 minutes) for your first authenticated call.