Skip to main content

Base URLs

Decibel API supports two environments: Netna:
https://api.netna.aptoslabs.com/decibel
Testnet:
https://api.testnet.aptoslabs.com/decibel
Note about the API URL: The base URLs provide access to all Decibel markets and trading functionality. This includes perpetual futures markets, spot markets, and more.

Package Addresses

Each environment has its own package address: Netna Package Address:
0xb8a5788314451ce4d2fbbad32e1bad88d4184b73943b7fe5166eab93cf1a5a95
Testnet Package Address:
0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f
No authentication required: The endpoints in this guide are public and don’t require authentication headers like OAuth or JWT. However, you do still need a Decibel Node API key to access the node; simply pass it as the Authorization header on your requests, in the format:
Authorization: Bearer <NODE_API_KEY>
Base URL Variable: In the code examples below, BASE_URL refers to either: - https://api.netna.aptoslabs.com/decibel for Netna - https://api.testnet.aptoslabs.com/decibel for Testnet Make sure to set this variable in your code before making requests.

Step 1: Get Available Markets

Let’s start by fetching the list of available markets. We’ll use the Get Markets endpoint to retrieve all active trading markets.
import requests

NODE_API_KEY = "YOUR_NODE_API_KEY"
headers = {"Authorization": f"Bearer {NODE_API_KEY}"}

# Make a GET request to the markets endpoint

response = requests.get(f"{BASE_URL}/api/v1/markets", headers=headers)

# Check if the request was successful

if response.status_code == 200:
markets = response.json()
print(f"Found {len(markets)} markets") # Print first 5 markets
for market in markets[:5]:
print(f"- {market.get('symbol', 'N/A')}: {market.get('name', 'N/A')}")
else:
print(f"Error: {response.status_code}")
print(response.text)

Step 2: Get Market Details

Once you have a list of markets, you can fetch detailed information about a specific market, including its current price, order book depth, and trading statistics.
import requests

NODE_API_KEY = "YOUR_NODE_API_KEY"
headers = {"Authorization": f"Bearer {NODE_API_KEY}"}

# Replace 'BTC-PERP' with an actual market symbol from Step 1

market_symbol = "BTC-PERP"

# Get market details

response = requests.get(f"{BASE_URL}/api/v1/markets/{market_symbol}", headers=headers)

if response.status_code == 200:
market = response.json()
print(f"Market: {market.get('symbol')}")
print(f"Last Price: {market.get('lastPrice', 'N/A')}")
print(f"24h Volume: {market.get('volume24h', 'N/A')}")
print(f"24h High: {market.get('high24h', 'N/A')}")
print(f"24h Low: {market.get('low24h', 'N/A')}")
else:
print(f"Error: {response.status_code}")
print(response.text)

Step 3: Get Order Book Data

Now let’s retrieve the order book for a market, which shows the current buy and sell orders with their prices and sizes.
import requests

NODE_API_KEY = "YOUR_NODE_API_KEY"
headers = {"Authorization": f"Bearer {NODE_API_KEY}"}

market_symbol = "BTC-PERP"

# Get order book (depth)

response = requests.get(
f"{BASE_URL}/api/v1/markets/{market_symbol}/orderbook",
params={"depth": 10}, # Get top 10 bids and asks
headers=headers,
)

if response.status_code == 200:
orderbook = response.json()
print("Bids (Buy Orders):")
for bid in orderbook.get("bids", [])[:5]:
print(f" Price: {bid['price']}, Size: {bid['size']}")

    print("\nAsks (Sell Orders):")
    for ask in orderbook.get("asks", [])[:5]:
        print(f"  Price: {ask['price']}, Size: {ask['size']}")

else:
print(f"Error: {response.status_code}")

Step 4: Get Recent Trades

Finally, let’s fetch recent trades for a market to see the latest trading activity.
import requests

NODE_API_KEY = "YOUR_NODE_API_KEY"
headers = {"Authorization": f"Bearer {NODE_API_KEY}"}

market_symbol = "BTC-PERP"

# Get recent trades

response = requests.get(
f"{BASE_URL}/api/v1/markets/{market_symbol}/trades",
params={"limit": 10}, # Get last 10 trades
headers=headers,
)

if response.status_code == 200:
trades = response.json()
print("Recent Trades:")
for trade in trades:
print(
f" Price: {trade.get('price')}, Size: {trade.get('size')}, "
f"Side: {trade.get('side')}, Time: {trade.get('timestamp')}"
)
else:
print(f"Error: {response.status_code}")