Integration Examples and Building API Clients
Speed up your development by using ready-made code samples for interacting with the AsterDEX API as the foundation for your own clients.
Why Build Your Own Client?
While the official SDKs (Software Development Kits) for the AsterDEX API are in active development, you can start integrating today by building your own API client. This gives you full control over the code and lets you implement any logic, however unconventional.
On this page we have collected code examples for popular programming languages that serve as an excellent starting point. They cover all the key aspects: sending requests, authentication and response handling.
Python SDK
The official Python library, ideally suited for building trading bots, data-analysis scripts and automation.
Installation
pip install asterdex-sdk
Usage example
from asterdex_sdk import AsterDexClient
# Use environment variables for security
api_key = "YOUR_API_KEY"
secret_key = "YOUR_SECRET_KEY"
client = AsterDexClient(api_key, secret_key)
try:
# Fetching the balance
balance = client.get_account_balance()
print("Баланс получен:", balance)
# Placing a limit order
order_params = {
"symbol": "BTCUSDT",
"side": "BUY",
"type": "LIMIT",
"quantity": 0.01,
"price": 25000,
"timeInForce": "GTC"
}
new_order = client.place_order(order_params)
print("Ордер размещен:", new_order)
except Exception as e:
print(f"Произошла ошибка: {e}")
JavaScript / TypeScript Example
A code example for building a client on Node.js. The same approach can be adapted for web applications.
Installing dependencies
npm install ws axios
Usage example (TypeScript)
import { AsterDexClient, OrderSide, OrderType } from '@asterdex/sdk';
const client = new AsterDexClient({
apiKey: 'YOUR_API_KEY',
apiSecret: 'YOUR_SECRET_KEY',
});
async function main() {
try {
const serverTime = await client.fetchServerTime();
console.log('Время сервера:', serverTime);
const order = await client.placeOrder({
symbol: 'ETHUSDT',
side: OrderSide.SELL,
type: OrderType.MARKET,
quantity: 0.1,
});
console.log('Ордер успешно размещен:', order);
} catch (error) {
console.error('Ошибка при работе с API:', error);
}
}
main();
Go SDK
A high-performance library for Go, built and maintained by the community. Ideal for applications where maximum speed and low resource consumption matter.
Installation
go get github.com/community/asterdex-go-sdk
Usage example
package main
import (
"context"
"fmt"
"github.com/community/asterdex-go-sdk/client"
"github.com/community/asterdex-go-sdk/models"
)
func main() {
apiKey := "YOUR_API_KEY"
secretKey := "YOUR_SECRET_KEY"
cli := client.NewClient(apiKey, secretKey)
// Pinging the server
err := cli.NewPingService().Do(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Пинг успешен")
// Creating an order
order, err := cli.NewCreateOrderService().
Symbol("BTCUSDT").
Side(models.SideTypeBuy).
Type(models.OrderTypeLimit).
Quantity("0.001").
Price("20000").
TimeInForce(models.TimeInForceTypeGTC).
Do(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Ордер создан:", order)
}
Want to Contribute?
We welcome community-built and community-maintained libraries for other languages (Rust, C#, Java, etc.). If you have created your own library and would like it to be added to this page, please get in touch.
All the required endpoints and rules can be found in the main API documentation.