Skip to main content

What is the Decibel TypeScript SDK?

The SDK provides a clean, typed interface to interact with Decibel on Aptos:
Both DecibelReadDex and DecibelWriteDex require a Node API token for authentication. Without one, all requests return 401 Unauthorized: anonymous requests are not allowed. Get yours from Geomi before starting.
More SDKs coming soon. Rust SDK is in development. For other languages, use the REST API or WebSocket API directly.
  • Read operations: DecibelReadDex - query markets, depth, prices, trades, positions, orders, Trading Accounts, vaults.
  • Write operations: DecibelWriteDex - place/cancel orders, manage positions and Trading Accounts, vault operations, delegation.

Installation

Install the SDK and required peer dependencies for Node or browser environments.

Read SDK

Market data, account state, orders, positions, and historical data.

Write SDK

Trading, position management, TP/SL, TWAP, Trading Accounts, and vault transactions.

Quick start

Read: market and account data

import { DecibelReadDex, TESTNET_CONFIG } from "@decibeltrade/sdk";

const read = new DecibelReadDex(TESTNET_CONFIG, {
  // Required: used to send Authorization: Bearer <YOUR_NODE_API_KEY> on node requests
  nodeApiKey: process.env.APTOS_NODE_API_KEY!,
});

const markets = await read.markets.getAll();
const account = await read.accountOverview.getByAddr("0x...account");

Write: submit transactions

import { DecibelWriteDex, TESTNET_CONFIG } from "@decibeltrade/sdk";
import { Ed25519Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";

const account = new Ed25519Account({
  privateKey: new Ed25519PrivateKey(process.env.PRIVATE_KEY!),
});

const write = new DecibelWriteDex(TESTNET_CONFIG, account, {
  // Required: used to send Authorization: Bearer <YOUR_NODE_API_KEY> on node requests
  nodeApiKey: process.env.APTOS_NODE_API_KEY!,
  // Defaults: simulate before submit, fee payer enabled
});

When to use which

  • Use DecibelReadDex when you need market data, order/position history, or account state. No private keys required.
  • Use DecibelWriteDex for on-chain actions and trading. In browsers, avoid embedding private keys; prefer session keys or a wallet and pass accountOverride for specific calls.
  • Configuration and network presets: MAINNET_CONFIG, TESTNET_CONFIG, LOCAL_CONFIG, DOCKER_CONFIG, NAMED_CONFIGS
  • See REST and WebSocket topics in Quick Start for direct API access.