API Documentation
Historical Trades API
API endpoint for retrieving historical trade data for specific trading pairs
Retrieves historical trade data for a specific trading pair.
Endpoint
GET /v1/spot/historical_tradesBase URL
https://dev-backend.pixpel.ioQuery Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
chain | number | Yes | 1482601649 | Blockchain chain ID |
ticker_id | string | Yes | - | Trading pair identifier (format: BASE_TARGET) |
type | string | No | "all" | Trade type filter: "buy", "sell", or "all" |
limit | number | No | 100 | Maximum number of trades to return (0 = all) |
start_time | string | No | - | Unix timestamp - filter trades after this time |
end_time | string | No | - | Unix timestamp - filter trades before this time |
Request Examples
Get all trades for a pair:
curl -X GET "https://dev-backend.pixpel.io/v1/spot/historical_trades?chain=1482601649&ticker_id=0x123abc_0x456def"Get last 50 buy trades:
curl -X GET "https://dev-backend.pixpel.io/v1/spot/historical_trades?chain=1482601649&ticker_id=0x123abc_0x456def&type=buy&limit=50"Get trades within time range:
curl -X GET "https://dev-backend.pixpel.io/v1/spot/historical_trades?chain=1482601649&ticker_id=0x123abc_0x456def&start_time=1699200000&end_time=1699286400"JavaScript/TypeScript:
const params = new URLSearchParams({
chain: '1482601649',
ticker_id: '0x123abc_0x456def',
type: 'all',
limit: '100'
});
const response = await fetch(`https://dev-backend.pixpel.io/v1/spot/historical_trades?${params}`);
const trades = await response.json();Python:
import requests
params = {
'chain': 1482601649,
'ticker_id': '0x123abc_0x456def',
'type': 'all',
'limit': 100
}
response = requests.get('https://dev-backend.pixpel.io/v1/spot/historical_trades', params=params)
trades = response.json()Response Schema
{
"success": true,
"statusCode": 200,
"message": "Success",
"data": {
"buy": [
{
"trade_id": 0,
"price": 0,
"base_volume": "string",
"target_volume": "string",
"trade_timestamp": 0,
"type": "buy"
}
],
"sell": [
{
"trade_id": 0,
"price": 0,
"base_volume": "string",
"target_volume": "string",
"trade_timestamp": 0,
"type": "sell"
}
]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
trade_id | number | Unique trade identifier (block_number * 1000 + index) |
price | number | Trade execution price as decimal number (6 decimal precision) |
base_volume | string | Amount of base currency traded (6 decimal places) |
target_volume | string | Amount of target currency traded (6 decimal places) |
trade_timestamp | number | Unix timestamp in milliseconds |
type | string | Trade type: "buy" or "sell" |
Trade Type Logic
- Buy Trade:
amount0In > 0andamount1Out > 0(swapping base for target)
Price =amount1Out / amount0In - Sell Trade:
amount1In > 0andamount0Out > 0(swapping target for base)
Price =amount1In / amount0Out
Example Response
{
"success": true,
"statusCode": 200,
"message": "Success",
"data": {
"buy": [
{
"trade_id": 123456001,
"price": 1.234567,
"base_volume": "100.000000",
"target_volume": "123.456700",
"trade_timestamp": 1699200000000,
"type": "buy"
},
{
"trade_id": 123457001,
"price": 1.235000,
"base_volume": "50.000000",
"target_volume": "61.750000",
"trade_timestamp": 1699201000000,
"type": "buy"
}
],
"sell": [
{
"trade_id": 123458001,
"price": 1.230000,
"base_volume": "75.000000",
"target_volume": "92.250000",
"trade_timestamp": 1699202000000,
"type": "sell"
}
]
}
}Error Responses
400 Bad Request - Missing ticker_id:
{
"success": false,
"statusCode": 400,
"message": "ticker_id is required"
}400 Bad Request - Invalid ticker_id format:
{
"success": false,
"statusCode": 400,
"message": "Invalid ticker_id format. Expected: BASE_TARGET"
}404 Not Found - Pair doesn't exist:
{
"success": false,
"statusCode": 404,
"message": "Pair not found"
}500 Internal Server Error:
{
"success": false,
"statusCode": 500,
"message": "Error retrieving historical trades"
}