upstox-python

Upstox Developer API – Example Code

This folder contains ready-to-use Python samples for the Upstox API. Each example shows how to call the API using the official Upstox Python SDK (upstox_client).

Why use these samples?

Use these samples to build trading apps, dashboards, or integrations without guessing request shapes or SDK usage.

Prerequisites

For full setup, sandbox mode, and auth flow, see the main Upstox Python SDK README in the repo root.

Folder structure

Samples are grouped by API area. Each .md file contains one or more Python snippets you can run after replacing placeholders like {your_access_token} and {your_client_id}.

Folder Description
login/ Authentication: get token from auth code, access-token request, logout.
user/ User profile, fund and margin details.
orders/ Order lifecycle: place (single/multi, v2 & v3), modify, cancel, order book, order details, order history, trades, historical trades, exit all positions.
portfolio/ Positions, holdings, MTF positions, convert positions.
market-quote/ LTP, full market quotes, OHLC (v2 & v3), option Greeks.
historical-data/ Historical and intraday candle data (v2 & v3).
option-chain/ Option contracts, put-call option chain.
expired-instruments/ Expiries, expired future/option contracts, expired historical candle data.
market-information/ Exchange status, market timings, market holidays.
gtt-orders/ Place, modify, cancel, and get details for GTT (Good Till Triggered) orders.
margins/ Margin details.
charges/ Brokerage details.
trade-profit-and-loss/ P&L report, report metadata, trade charges.

Documentation