API Reference

v1

Integrate real-world asset execution cost comparison into your application. Query live data from multiple perpetual DEXs with a single API call.

Introduction

The Real World Perps API provides programmatic access to execution cost comparisons across multiple perpetual DEXs. Use it to find the best venue for trading real-world assets like gold, forex, and equities.

The API returns real-time data including slippage estimates, fee calculations, liquidity checks, and identifies the lowest-cost venue for your trade parameters.

Base URL

All API requests should be made to the following base URL:

https://api.realworldperps.xyz

Authentication

The API is currently open and does not require authentication. This may change in the future for rate limiting purposes.

# No authentication required
curl "https://api.realworldperps.xyz/api/compare/XAU?size=100000&direction=long"

Endpoints

The API currently provides one main endpoint for comparing execution costs across all supported exchanges.

Compare Costs

GET/api/compare/{asset}

Compare execution costs for a specific asset across all supported perpetual DEXs. Returns real-time slippage, fees, and liquidity data for each exchange.

Request Parameters

Path Parameters

ParameterTypeDescription
assetrequiredstringAsset identifier (e.g., XAU, XAG, EURUSD, AAPL)

Query Parameters

ParameterTypeDescription
sizerequirednumberOrder size in USD (e.g., 100000 for $100,000)
directionrequiredstringTrade direction: "long" or "short"
order_typestringOrder type: "taker" (default) or "maker"

Example Request

curl "https://api.realworldperps.xyz/api/compare/XAU?size=100000&direction=long&order_type=taker"

Response Schema

The response contains metadata about the request, results from each exchange, and the winning (lowest cost) venue.

Top-Level Fields

ParameterTypeDescription
assetstringFull asset name (e.g., "XAU/USD")
symbol_keystringAsset identifier used in request
order_size_usdnumberRequested order size in USD
order_typestringOrder type (taker/maker)
directionstringTrade direction (long/short)
winnerstringExchange with lowest total cost
winner_cost_bpsnumberWinning exchange total cost in bps
symbolsobjectAsset symbol mapping for each exchange
hyperliquidobject | nullHyperliquid exchange result
lighterobject | nullLighter exchange result
asterobject | nullAster exchange result
avantisobject | nullAvantis exchange result
ostiumobject | nullOstium exchange result
extendedobject | nullExtended exchange result
edgexobject | nullEdgeX exchange result
grvtobject | nullGRVT exchange result

Exchange Fields

Each exchange object contains the following fields. Some fields may be null or absent if not applicable to that exchange.

Cost Fields (in basis points)

ParameterTypeDescription
opening_slippage_bpsnumberSlippage cost when opening position
closing_slippage_bpsnumberSlippage cost when closing position
open_fee_bpsnumberFee charged on open
close_fee_bpsnumberFee charged on close
total_cost_bpsnumberTotal round-trip cost
effective_spread_bpsnumberEffective bid-ask spread

Holding Fee Fields

Holding fees are based on the platform's hourly funding/margin rate extrapolated to 24 hours. Symmetric exchanges return a single rate; directional exchanges (Avantis, Ostium) return separate long/short rates.

ParameterTypeDescription
holding_fee_1h_pctnumberHourly holding fee as % of notional (symmetric exchanges)
holding_fee_24h_pctnumber24-hour holding fee as % of notional (symmetric exchanges)
holding_fee_1h_long_pctnumberHourly holding fee for longs (directional exchanges)
holding_fee_1h_short_pctnumberHourly holding fee for shorts (directional exchanges)
holding_fee_24h_long_pctnumber24-hour holding fee for longs (directional exchanges)
holding_fee_24h_short_pctnumber24-hour holding fee for shorts (directional exchanges)

Execution Fields

ParameterTypeDescription
executedboolean | stringWhether full order can be filled. "PARTIAL" if partial fill.
filledbooleanTrue if order fully filled
filled_usdnumberAmount that can be filled in USD
unfilled_usdnumberAmount that cannot be filled
max_leveragenumberMaximum leverage available

Price Fields

ParameterTypeDescription
mid_pricenumberMid-market price
best_bidnumberBest bid price (order book exchanges)
best_asknumberBest ask price (order book exchanges)
symbolstringExchange-specific symbol
timestampnumberUnix timestamp of data

Buy/Sell Breakdown

The buy and sell objects contain per-side execution details:

ParameterTypeDescription
avg_pricenumberAverage execution price for this side
slippage_bpsnumberSlippage for this side in bps
filled_usdnumberAmount filled for this side
unfilled_usdnumberAmount unfilled for this side
levels_usednumberOrder book levels consumed

Examples

Full Response Example

Response for a $100,000 long position on Gold (XAU):

{
  "asset": "XAU/USD",
  "symbol_key": "XAU",
  "order_size_usd": 100000.0,
  "order_type": "taker",
  "direction": "long",
  "winner": "ostium",
  "winner_cost_bps": 2.89,
  "symbols": {
    "hyperliquid": "xyz:GOLD",
    "lighter": "XAU",
    "aster": "XAUUSDT",
    "avantis": "XAU",
    "ostium": "XAUUSD",
    "extended": "XAU-USD",
    "edgex": "XAU-USD",
    "grvt": "XAU_USDT"
  },
  "hyperliquid": {
    "exchange": "hyperliquid",
    "symbol": "xyz:GOLD",
    "executed": true,
    "filled": true,
    "filled_usd": 100000.0,
    "opening_slippage_bps": 1.06,
    "closing_slippage_bps": 1.03,
    "open_fee_bps": 9.0,
    "close_fee_bps": 9.0,
    "total_cost_bps": 20.09,
    "holding_fee_1h_pct": 0.00018,
    "holding_fee_24h_pct": 0.0042,
    "max_leverage": 20,
    "mid_price": 5139.05,
    "best_bid": 5139.0,
    "best_ask": 5139.1,
    "timestamp": 1771947188.14,
    "buy": {
      "avg_price": 5139.59,
      "slippage_bps": 1.06,
      "filled_usd": 100000.0,
      "levels_used": 6
    },
    "sell": {
      "avg_price": 5138.51,
      "slippage_bps": 1.03,
      "filled_usd": 100000.0,
      "levels_used": 5
    }
  },
  "ostium": {
    "exchange": "ostium",
    "symbol": "XAUUSD",
    "executed": true,
    "filled": true,
    "opening_slippage_bps": 0.69,
    "closing_slippage_bps": 0.69,
    "open_fee_bps": 1.5,
    "close_fee_bps": 0.0,
    "total_cost_bps": 2.89,
    "holding_fee_1h_long_pct": 0.00021,
    "holding_fee_1h_short_pct": -0.00015,
    "holding_fee_24h_long_pct": 0.005,
    "holding_fee_24h_short_pct": -0.0036,
    "max_leverage": 100.0,
    "mid_price": 5137.39,
    "timestamp": 1771947189.58
  }
  // ... other exchanges (lighter, aster, avantis, extended, edgex, grvt)
}

JavaScript Example

const response = await fetch(
  'https://api.realworldperps.xyz/api/compare/XAU?size=100000&direction=long'
);
const data = await response.json();

console.log(`Best venue: ${data.winner}`);
console.log(`Total cost: ${data.winner_cost_bps} bps`);

// Calculate USD cost
const usdCost = (data.order_size_usd * data.winner_cost_bps) / 10000;
console.log(`USD cost: $${usdCost.toFixed(2)}`);

Python Example

import requests

response = requests.get(
    'https://api.realworldperps.xyz/api/compare/XAU',
    params={
        'size': 100000,
        'direction': 'long',
        'order_type': 'taker'
    }
)
data = response.json()

print(f"Best venue: {data['winner']}")
print(f"Total cost: {data['winner_cost_bps']:.2f} bps")

# Get individual exchange costs
for exchange in ['hyperliquid', 'lighter', 'aster', 'avantis', 'ostium', 'extended', 'edgex', 'grvt']:
    if data.get(exchange):
        cost = data[exchange].get('total_cost_bps', 'N/A')
        print(f"  {exchange}: {cost} bps")

Error Handling

The API uses standard HTTP status codes to indicate success or failure.

Status CodeMeaning
200Success - comparison data returned
400Bad Request - invalid parameters
404Not Found - asset not supported
500Server Error - try again later
503Service Unavailable - exchange API down

Error Response Format

{
  "error": "Invalid asset",
  "message": "Asset 'INVALID' is not supported",
  "supported_assets": ["XAU", "XAG", "EURUSD", "GBPUSD", ...]
}

Supported Assets

The following assets are supported. Use the asset key in the API path.

Asset KeyNameCategory
XAUGoldCommodities
XAGSilverCommodities
EURUSDEuro / US DollarForex
GBPUSDBritish Pound / US DollarForex
USDJPYUS Dollar / Japanese YenForex
AAPLApple Inc.Equities
MSFTMicrosoft CorporationEquities
GOOGAlphabet Inc.Equities
AMZNAmazon.com Inc.Equities
METAMeta Platforms Inc.Equities
NVDANVIDIA CorporationEquities
TSLATesla Inc.Equities
SPYS&P 500 ETFIndices
QQQNasdaq 100 ETFIndices
COINCoinbase Global Inc.Equities

Rate Limits

The API currently has generous rate limits suitable for most use cases:

  • 20 requests per 10 seconds per IP address

If you need higher limits for production use, please contact us.

Rate limit headers are included in responses:

X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000

Need help? Check the methodology docs or reach out.

← Back to comparison tool