Skip to main content

🔁 zex-sdk

A Python SDK for the Zex Exchange – a decentralized exchange (DEX) designed to deliver the speed, usability, and reliability of centralized exchanges (CEXs) while preserving the security and control of a DEX.

zex-sdk provides a seamless interface to interact with Zex Exchange's API, including essential trading, balance management, and live socket streaming capabilities.


🚀 Features

  • 📥 Place and cancel orders (single or batch)
  • 🧾 Register user accounts
  • 💰 Query account balances and user information
  • 📈 Retrieve live market prices
  • 🔄 Deposit and withdraw assets
  • 🔔 Live execution reports via WebSocket stream

📦 Installation

Install directly from PyPI:

pip install zex-sdk

⚡ Quick Start

Here's how to get started with the async Zex client in just a few lines of code.

import asyncio
from zex.sdk import AsyncClient

async def main():
    # Create a Zex client instance (testnet is True by default)
    client = await AsyncClient.create(api_key="your-api-key")

    # Example: get the price of ETH/USDT
    price = await client.get_price("ETH-USDT")
    print("Current price:", price)

asyncio.run(main())

Note: Use AsyncClient.create(...) instead of the constructor. It handles registration and setup for you.


📘 Usage Examples

Here are some common usage examples using the AsyncClient and ZexSocketManager.


✅ Place a Batch of Orders

from zex_sdk.models import PlaceOrderRequest, OrderSide

orders = [
    PlaceOrderRequest(
        base_token="ETH",
        quote_token="USDT",
        side=OrderSide.BUY,
        volume=0.5,
        price=1900.0
    ),
    PlaceOrderRequest(
        base_token="BTC",
        quote_token="USDT",
        side=OrderSide.SELL,
        volume=0.1,
        price=30000.0
    ),
]

await client.place_batch_order(orders)

❌ Cancel a Batch of Orders

# Suppose you have stored signed orders
signed_orders = [...] # List[bytes]

await client.cancel_batch_order(signed_orders)

📈 Get Current Market Price

price = await client.get_price("ETH-USDT")
print("ETH price:", price)

🔔 Listen to Execution Reports in Real-Time

from zex_sdk.socket import ZexSocketManager

async def on_execution_report(message):
    print("Execution report received:", message)

socket_manager = ZexSocketManager(client)

# Use async context manager to open and manage the socket
async with await socket_manager.execution_report_socket(on_execution_report):
await asyncio.sleep(60) # keep listening for 60 seconds

Metadata

Release files for zex-sdk 0.5.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 zex-sdk 0.5.0
File Size Uploaded
zex_sdk-0.5.0.tar.gz 19.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zex-sdk 0.5.0
File Interpreter ABI Platform
zex_sdk-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.9 kB

Release files / zex_sdk-0.5.0.tar.gz

Download URL zex_sdk-0.5.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
733fa56b5643014a3bfc6f3057c7aa0760be274f7fb4bcdd3c692949b406a31f
BLAKE2b-256 checksum
How to use checksums
7b0a6d29cc0399495b346b06138c18f3d5f40092a2d376bc8ce202dde32f1447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.0 CPython/3.11.14 Linux/6.14.0-1012-azure

Release files / zex_sdk-0.5.0-py3-none-any.whl

Download URL zex_sdk-0.5.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c03261b04ddf33bf90b67ec230cea1e03651d54966b548f78240ae605ef3651
BLAKE2b-256 checksum
How to use checksums
40b6c7a1faf99b79d814ce6daab68deac86747547944acbe7985e929afa43a8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.0 CPython/3.11.14 Linux/6.14.0-1012-azure

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.2

2 release files

0.1.0

2 release files

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