This guide will help you get up and running with the GDEX SDK in minutes.
Install the SDK directly from GitHub:
# Using npm
npm install github:TheArcadiaGroup/gdex-sdk
# Using yarn
yarn add github:TheArcadiaGroup/gdex-sdk
# Using pnpm
pnpm add github:TheArcadiaGroup/gdex-sdkimport { GdexClient } from '@gdex/sdk';
const client = new GdexClient({
apiKey: 'your-api-key-here',
});// Get all tradeable assets
const assets = await client.getAssets();
console.log(`Total assets: ${assets.length}`);
// Display first 5 assets
assets.slice(0, 5).forEach(asset => {
console.log(`${asset.coin}: $${asset.markPx} (${asset.maxLeverage}x max leverage)`);
});Example Output:
Total assets: 343
BTC: $76240.0 (50x max leverage)
ETH: $2850.0 (50x max leverage)
SOL: $125.0 (20x max leverage)
vntl:SPACEX: $150.0 (3x max leverage)
xyz:GOLD: $2650.0 (10x max leverage)
const walletAddress = '0xYourWalletAddress';
const state = await client.getAccountState(walletAddress);
if (state) {
console.log(`Withdrawable: $${state.withdrawable}`);
console.log(`Account Value: $${state.crossMarginSummary.accountValue}`);
console.log(`Open Positions: ${state.assetPositions.length}`);
}// Market buy 0.01 BTC
const result = await client.createOrder('userId', 'signature', {
coin: 'BTC',
isLong: true,
price: '76000',
size: '0.01',
isMarket: true,
});
if (result.isSuccess) {
console.log('Order placed successfully!');
console.log('Order ID:', result.retData?.response?.data?.statuses[0]?.resting?.oid);
} else {
console.error('Order failed:', result.error);
}const client = new GdexClient({
// Required: Your API key
apiKey: 'your-api-key',
// Optional: Custom API endpoint (default: production)
baseUrl: 'https://api.gdex.io/v1',
// Optional: Request timeout in ms (default: 30000)
timeout: 60000,
});const client = new GdexClient({
apiKey: process.env.GDEX_API_KEY!,
// Uses default production URL
});const client = new GdexClient({
apiKey: process.env.GDEX_STAGING_API_KEY!,
baseUrl: 'https://staging-api.gdex.io/v1',
});The SDK is written in TypeScript and includes full type definitions:
import {
GdexClient,
GdexConfig,
HLAsset,
CreateOrderParams,
OrderResponse,
} from '@gdex/sdk';
// Full autocomplete and type checking
const config: GdexConfig = {
apiKey: 'my-key',
};
const client = new GdexClient(config);
const params: CreateOrderParams = {
coin: 'BTC',
isLong: true,
price: '50000',
size: '0.1',
};- Trading Guide - Learn how to place orders, set TP/SL, and manage positions
- HIP-3 Assets - Trade on builder-deployed perp DEXes
- Copy Trading - Automatically copy successful traders
- API Reference - Complete method documentation