User Trade History
Description
Get trade history for a specific trading pair.
HTTP Request
GET /fapi/v1/userTrades (HMAC SHA256)
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | STRING | YES | Trading pair |
| orderId | STRING | NO | System order ID (UUID) — restricts the result to fills of one order |
| startTime | LONG | NO | Start time (ms) |
| endTime | LONG | NO | End time (ms) |
| fromId | LONG | NO | Millisecond-timestamp lower bound — only trades executed at or after this time are returned. This is not a trade-ID cursor: trade IDs are UUIDs and cannot be paged numerically. |
| limit | INT | NO | Default 500; Max 1000 |
| timestamp | LONG | YES | Timestamp |
There is no age cutoff — older trades remain queryable.
Response Example
[
{
"symbol": "BTCUSDT",
"id": "0fbb7679-7960-41b1-8025-054450129024",
"orderId": "b8bab68c-d41b-462b-8a9e-d451ac1e1665",
"side": "BUY",
"price": "6921.00",
"qty": "1.000",
"quoteQty": "6921.00",
"realizedPnl": "-0.01503",
"commission": "0.00000000",
"commissionAsset": "USDT",
"time": 1569069506613,
"buyer": true,
"maker": false
}
]
Code Examples
cURL
API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="symbol=BTCUSDT&limit=500×tamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -H "X-MBX-APIKEY: ${API_KEY}" \
"https://api.prex.world/fapi/v1/userTrades?${QUERY_STRING}&signature=${SIGNATURE}"
Python
import time, hmac, hashlib, requests
API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.prex.world"
def sign(params: str) -> str:
return hmac.new(API_SECRET.encode(), params.encode(), hashlib.sha256).hexdigest()
def signed_get(path, params={}):
params["timestamp"] = int(time.time() * 1000)
qs = "&".join(f"{k}={v}" for k, v in params.items())
params["signature"] = sign(qs)
return requests.get(f"{BASE_URL}{path}", params=params, headers={"X-MBX-APIKEY": API_KEY})
# Get user trades for BTCUSDT
resp = signed_get("/fapi/v1/userTrades", params={
"symbol": "BTCUSDT",
"limit": "500"
})
print(resp.json())