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
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /prices | No | Get all provider prices |
| GET | /balance | Yes | Get TRX and USDT balance |
| POST | /orders | Yes | Create energy or bandwidth order |
| GET | /orders | Yes | List orders with optional status filter |
| GET | /orders/:id | Yes | Get order details with fills |
| GET | /history | Yes | Transaction history |
| GET | /history/summary | Yes | History summary and stats |
| POST | /withdraw | Yes | Initiate TRX withdrawal |
| GET | /deposit | Yes | Get deposit address and memo |
| POST | /keys | Yes | Create new API key |
| GET | /keys | Yes | List all API keys |
| DELETE | /keys/:id | Yes | Revoke an API key |
Endpoint details
GET /prices
Returns current prices from all connected providers. No authentication required.
curl https://merx.exchange/api/v1/pricesPOST /orders
Create a new energy or bandwidth order. Supports Idempotency-Key header to prevent duplicate orders on retry.
{
"resource_type": "ENERGY",
"amount": 65000,
"duration_sec": 86400,
"target_address": "TYourTargetAddressHere",
"max_price_sun": 90
}| Field | Type | Required | Description |
|---|---|---|---|
| resource_type | string | Yes | ENERGY or BANDWIDTH |
| amount | number | Yes | Amount of resource to purchase |
| duration_sec | number | Yes | Duration in seconds |
| target_address | string | Yes | TRON address to receive the delegation |
| max_price_sun | number | No | Maximum price per unit in SUN |
POST /withdraw
Initiate a TRX withdrawal to an external TRON address. Supports Idempotency-Key.
{
"amount_sun": "10000000",
"to_address": "TYourExternalAddressHere"
}GET /deposit
Returns the deposit address and memo for funding your Merx account.
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": {
"code": "INSUFFICIENT_BALANCE",
"message": "Not enough TRX to cover this order",
"details": {
"required_sun": "5460000",
"available_sun": "2000000"
}
}
}Common error codes
| Code | HTTP | Description |
|---|---|---|
| UNAUTHORIZED | 401 | Missing or invalid API key |
| FORBIDDEN | 403 | Key does not have required permissions |
| NOT_FOUND | 404 | Resource does not exist |
| VALIDATION_ERROR | 422 | Invalid request parameters |
| INSUFFICIENT_BALANCE | 422 | Not enough funds |
| RATE_LIMITED | 429 | Too many requests |
| INTERNAL_ERROR | 500 | Server 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 group | Limit |
|---|---|
| Prices | 300 req/min |
| Default (balance, keys, deposit) | 100 req/min |
| History | 60 req/min |
| Orders | 10 req/min |
| Withdraw | 5 req/min |