API Reference

Base URL: https://merx.exchange/api/v1 — All requests and responses use JSON. Authenticated endpoints require an X-API-Key header or Bearer JWT.

Authentication

Pass your API key via the X-API-Key header. Alternatively, use a Bearer JWT obtained from the login flow. All endpoints marked "auth" will return 401 without a valid credential.

Endpoints

MethodPathAuthDescription
GET/pricesNoGet all provider prices
GET/balanceYesGet TRX and USDT balance
POST/ordersYesCreate energy or bandwidth order
GET/ordersYesList orders with optional status filter
GET/orders/:idYesGet order details with fills
GET/historyYesTransaction history
GET/history/summaryYesHistory summary and stats
POST/withdrawYesInitiate TRX withdrawal
GET/depositYesGet deposit address and memo
POST/keysYesCreate new API key
GET/keysYesList all API keys
DELETE/keys/:idYesRevoke an API key

Endpoint details

GET /prices

Returns current prices from all connected providers. No authentication required.

bash
curl https://merx.exchange/api/v1/prices

POST /orders

Create a new energy or bandwidth order. Supports Idempotency-Key header to prevent duplicate orders on retry.

Request bodyjson
{
  "resource_type": "ENERGY",
  "amount": 65000,
  "duration_sec": 86400,
  "target_address": "TYourTargetAddressHere",
  "max_price_sun": 90
}
FieldTypeRequiredDescription
resource_typestringYesENERGY or BANDWIDTH
amountnumberYesAmount of resource to purchase
duration_secnumberYesDuration in seconds
target_addressstringYesTRON address to receive the delegation
max_price_sunnumberNoMaximum price per unit in SUN

POST /withdraw

Initiate a TRX withdrawal to an external TRON address. Supports Idempotency-Key.

Request bodyjson
{
  "amount_sun": "10000000",
  "to_address": "TYourExternalAddressHere"
}

GET /deposit

Returns the deposit address and memo for funding your Merx account.

bash
curl https://merx.exchange/api/v1/deposit \
  -H "X-API-Key: sk_live_your_key_here"

Error format

All errors follow a consistent structure. The HTTP status code matches the error type. The response body always contains an error object with code, message, and optional details.

Error responsejson
{
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Not enough TRX to cover this order",
    "details": {
      "required_sun": "5460000",
      "available_sun": "2000000"
    }
  }
}

Common error codes

CodeHTTPDescription
UNAUTHORIZED401Missing or invalid API key
FORBIDDEN403Key does not have required permissions
NOT_FOUND404Resource does not exist
VALIDATION_ERROR422Invalid request parameters
INSUFFICIENT_BALANCE422Not enough funds
RATE_LIMITED429Too many requests
INTERNAL_ERROR500Server error

Rate limits

Rate limits are enforced per API key. When exceeded, the API returns 429 with a Retry-After header indicating seconds until the next window.

Endpoint groupLimit
Prices300 req/min
Default (balance, keys, deposit)100 req/min
History60 req/min
Orders10 req/min
Withdraw5 req/min