Delta Exchange Python SDK
A typed Python client for the Delta Exchange v2 REST API and real-time WebSocket feed.
It is based on the API snapshot in docs/delta-exchange-api-docs.md.
This is a community SDK. Test trading code on the demo environment before using real funds.
Features
- Public and signed REST requests
- Helpers for market data, orders, positions, wallets, account settings, MMP, and deadman switch
- Generic
request()method for newly released v2 endpoints - Cursor pagination iterator
- Async WebSocket client with
key-auth, heartbeat monitoring, reconnection, and subscription replay - Built-in India/global REST and India WebSocket endpoint selection
- Structured exceptions and complete type hints
Install
pip install delta-rest-ws
Python 3.9 or newer is required.
REST quick start
Public endpoints need no credentials:
from delta_rest_ws import DeltaRestClient, Environment
client = DeltaRestClient(environment=Environment.INDIA_TESTNET)
products = client.get_products({"states": "live"})
ticker = client.get_ticker("BTCUSD")
candles = client.get_candles(
symbol="BTCUSD",
resolution="5m",
start=1722511635,
end=1722598035,
)
client.close()
Private endpoints are signed automatically:
from delta_rest_ws import DeltaRestClient, Environment, OrderType
with DeltaRestClient(
environment=Environment.INDIA_TESTNET,
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
) as client:
order = client.place_order(
product_id=27,
size=1,
side="buy",
order_type=OrderType.LIMIT,
limit_price="50000",
client_order_id="strategy-001",
)
client.cancel_order(product_id=27, order_id=order["id"])
Do not commit API credentials. Read them from environment variables or a secrets manager.
Environments
| Environment | REST | Private WebSocket | Public WebSocket |
|---|---|---|---|
INDIA |
https://api.india.delta.exchange |
wss://socket.india.delta.exchange |
wss://public-socket.india.delta.exchange |
INDIA_TESTNET |
https://cdn-ind.testnet.deltaex.org |
wss://socket-ind.testnet.deltaex.org |
wss://socket-ind-pub.testnet.deltaex.org |
GLOBAL |
https://api.delta.exchange |
Pass url= explicitly |
Pass url= explicitly |
GLOBAL_TESTNET |
https://testnet-api.delta.exchange |
Pass url= explicitly |
Pass url= explicitly |
The bundled API documentation only declares India WebSocket URLs, so the SDK does not guess global socket endpoints.
Pagination
for page in client.iter_pages(
"/fills",
query={"contract_types": "perpetual_futures"},
):
for fill in page:
print(fill)
order_history() and fills() return the full API envelope so result and meta.after
remain available. Most other helpers return the result value directly.
Calling a new endpoint
result = client.request(
"GET",
"/v2/some_future_endpoint",
query={"symbol": "BTCUSD"},
auth=True,
)
WebSocket quick start
Subscriptions may be registered before connecting. They are sent on connect and restored after any reconnect.
import asyncio
from delta_rest_ws import Channel, DeltaWebSocketClient, Environment
async def main():
ws = DeltaWebSocketClient(
environment=Environment.INDIA_TESTNET,
public=True,
)
await ws.subscribe(Channel.TICKER, ["BTCUSD", "ETHUSD"])
await ws.subscribe("candlestick_1m", ["MARK:BTCUSD"])
try:
async for message in ws.messages():
print(message)
finally:
await ws.close()
asyncio.run(main())
Private streams authenticate before subscriptions are sent:
ws = DeltaWebSocketClient(
environment=Environment.INDIA_TESTNET,
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
)
await ws.subscribe(Channel.ORDERS, ["all"])
await ws.subscribe(Channel.POSITIONS, ["all"])
async for message in ws.messages():
print(message)
The client enables Delta's server heartbeat and uses a 40-second receive timeout by default. It also sends WebSocket ping frames every 30 seconds and expects a pong within 5 seconds.
Errors
from delta_rest_ws import DeltaAPIError, DeltaHTTPError
try:
client.get_profile()
except DeltaHTTPError as error:
print(error.status_code, error)
except DeltaAPIError as error:
print(error.code, error.context, error)
Development
python -m pip install -e ".[dev]"
ruff check .
pytest
python -m build
python -m twine check dist/*
License
MIT License.
Metadata
Release files for delta-rest-ws 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| delta_rest_ws-0.1.0.tar.gz | 10.8 kB | With provenance | Details for delta_rest_ws-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| delta_rest_ws-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for delta_rest_ws-0.1.0-py3-none-any.whl |
Total release size: 23.7 kB
Release files / delta_rest_ws-0.1.0.tar.gz
| Download URL | delta_rest_ws-0.1.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
779feb84960da47adc4a4afe790ebf2ab67b984c83e27ff279a9fe1cb2437914
|
|
BLAKE2b-256 checksum How to use checksums |
23cb7934be82d81d2a99779257141a290d729460e0d777057a1594abeebb395f
|
| 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 Aug 8, 2026.
Transparency logRelease files / delta_rest_ws-0.1.0-py3-none-any.whl
| Download URL | delta_rest_ws-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53db0a30ee985c383d7ac4964f69aef5f061851ac410923b868dbab0e473cca0
|
|
BLAKE2b-256 checksum How to use checksums |
fb2555bc859f0e567844d9a3250fce1a0e303ecf2c5fdd5aed86067bbcd80a67
|
| 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 Aug 8, 2026.
Transparency logSecurity for delta-rest-ws 0.1.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.
Attestation for delta_rest_ws-0.1.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 Aug 8, 2026.
Transparency logA 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.