Official SDKs

Integrate Levret Exchange into your applications with our official SDKs. Built for developers, by developers.

Node.js SDK

TypeScript & JavaScript support

Full TypeScript support
REST & WebSocket clients
Auto-completion & IntelliSense
Built-in error handling

Python SDK

Full Python support

Python 3.8+ support
REST & WebSocket clients
Async/await support
Exception handling

REST API Client

Complete REST API wrapper for all trading operations, account management, and market data

WebSocket Client

Real-time market data, order updates, and position changes via WebSocket connections

Market Data

Access to real-time price feeds, order books, candlestick data, and trade history

Trading Operations

Create, modify, and cancel orders with full support for all order types and strategies

Position Management

Manage positions, adjust leverage, add/reduce margin, and set stop-loss/take-profit

Secure Authentication

Built-in API key authentication with automatic signature generation and validation

Quick Start

Installation

Node.js
npm install @levret/node-sdk
# or
yarn add @levret/node-sdk
Python
pip install -r requirements.txt
# or
pip install requests python-socketio

Basic Usage

Node.js
import { TradingRESTClient, TradingWSClient } from '@levret/node-sdk'

// REST API Client
const restClient = new TradingRESTClient(
  'https://api.levret.io/api/v1',
  'YOUR_API_KEY_ID',
  'YOUR_API_KEY_SECRET'
)

// WebSocket Client
const wsClient = new TradingWSClient(
  'wss://api.levret.io',
  'YOUR_API_KEY_ID',
  'YOUR_API_KEY_SECRET'
)

// Connect to WebSocket
await wsClient.connect()

// Subscribe to market data
wsClient.subscribeMarketData('BTC_USDT')
wsClient.on('marketUpdate', (data) => {
  console.log('Market data:', data)
})

// Create an order
const order = await restClient.createOrder({
  userId: 'your-user-id',
  symbol: 'BTC_USDT',
  side: 'buy',
  orderType: 'limit',
  size: 0.01,
  price: 45000,
  leverage: 10
})

console.log('Order created:', order)

API Endpoints

Trading

createOrder() - Create new orders
cancelOrder() - Cancel specific orders
cancelAll() - Cancel all user orders
getOpenOrders() - Get active orders
getOrderById() - Get order details

Positions

getPositions() - Get user positions
updateLeverage() - Adjust position leverage
adjustMargin() - Add/reduce margin
updateTpSl() - Set stop-loss/take-profit

Market Data

getMarketData() - Get symbol ticker
getOrderBook() - Get order book depth
getKlines() - Get candlestick data
getTrades() - Get recent trades
getSymbols() - Get available symbols

Account

getAccountOverview() - Get account summary
getBalanceHistory() - Get balance history
getUserTrades() - Get user trade history
getOrderTrades() - Get order execution details

WebSocket Events

marketUpdate

Real-time price updates for subscribed symbols

orderBookUpdate

Order book depth changes

orderCreated

New order confirmation

orderUpdate

Order status changes (filled, cancelled, etc.)

positionUpdate

Position changes (P&L, margin, etc.)

tradeUpdate

New trade executions

Ready to Get Started?

Download our SDKs and start building your trading applications today. Join thousands of developers already using Levret Exchange.