Skip to main content

sahiapi

The official Python SDK for the Sahi trading APIs.

Build trading and investing workflows in Python: place and manage orders, track holdings, positions and funds, pull quotes, candles and option chains, and receive live ticks and order updates over WebSocket.

Sahi © 2026. Released under the MIT License.

Documentation

Features

  • Orders: place, modify and cancel orders, and read the order book and the trades behind each order.
  • Portfolio: holdings and open positions.
  • Funds: available balance and margin in use.
  • Market data: LTP and quotes for many instruments in one call, historical candles, option expiries and option chains.
  • Live streams: SahiFeed streams LTP, quotes and market depth, plus order updates, and reconnects and resubscribes on its own.
  • Typed errors: every API failure raises an exception carrying the HTTP status, error code, request id and a hint on how to fix it.

Installation

pip install sahiapi

Requires Python 3.9 or newer.

Quickstart

Create an API key in your Sahi account and approve it for the trading day, then connect:

import os
from sahiapi import SahiAPI

api = SahiAPI.from_credentials(
    key_id=os.environ["SAHI_KEY_ID"],
    secret=os.environ["SAHI_SECRET"],
)
print(api.get_profile())
print(api.get_funds())

Example: place a limit order

Prices are in paise, so ₹2,499.55 is 249955.

response = api.place_order(
    exchange_segment=SahiAPI.EXCHANGE_SEGMENT_NSE,
    symbol="RELIANCE",
    txn_type=SahiAPI.TXN_TYPE_BUY,
    qty=1,
    order_type=SahiAPI.ORDER_TYPE_LIMIT,
    product=SahiAPI.PRODUCT_DELIVERY,
    validity=SahiAPI.VALIDITY_DAY,
    price=249955,
)
order_id = response["order_ids"][0]
print(api.get_order_detail(order_id))

See the Python SDK documentation for streaming, market data and every other endpoint.

Metadata

Release files for sahiapi 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sahiapi 0.2.0
File Size Uploaded Provenance
sahiapi-0.2.0.tar.gz 51.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sahiapi 0.2.0
File Interpreter ABI Platform
sahiapi-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 110.9 kB

Release files / sahiapi-0.2.0.tar.gz

Download URL sahiapi-0.2.0.tar.gz
Size 51.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e425def832bd8930475bf26102511e54890a3a4c9a9fbd83cb062a4d84b6a3d4
BLAKE2b-256 checksum
How to use checksums
9875f0aea44e7d168e0b1fd34fc23f6fc21c723915ef9ee02de0838b49d6f91c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / sahiapi-0.2.0-py3-none-any.whl

Download URL sahiapi-0.2.0-py3-none-any.whl
Size 59.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c43df083b408fdfe994bb27adf1af80b0972733726d75f4a530896744ea0faf5
BLAKE2b-256 checksum
How to use checksums
f8f26f430247d1d36a91272dfef980cf9697997715c9d1c9aca7a01c6043ff0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for sahiapi 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sahiapi-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page