Get Aggregated Prices
This endpoint allows users to retrieve aggregated historical price data for a specific trading pair within a defined time range.
ATTENTION: You MUST Understandslot
andapi-key
Before Using the API! 🚨
Before making any API requests, it's critical to understand how the
slot
andapi-key
parameters work. These values ensure that your requests retrieve the correct data and are properly authenticated.📖 Click here to read the full explanation → Understanding
slot
andapi-key
Authentication
This endpoint requires an API KEY token. The token must be sent in the api-key
header.
Example:
api-key: <your_api_key_here>
If the token is invalid or missing, the API will return:
{
"statusCode": 401,
"message": "Unauthorized"
}
Endpoints
Retrieve Aggregated Prices
Method: GET
URL: /aggregated-prices/prices
Authentication: Required (API Key
)
Description: Returns aggregated price data for the specified trading pair within the given time range.
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
pair | string | Yes | The trading pair (e.g., BTCUSDT) |
slot | string | No | The price slot (default: "default") |
type | string | Yes | The asset type (e.g., "crypto") |
interval | string | Yes | Time interval for aggregation (e.g., "1m") |
skip | integer | No | Number of records to skip (default: 0) |
limit | integer | No | Maximum number of records to return (default: 1000) |
startTime | integer | Yes | Start time in milliseconds |
endTime | integer | Yes | End time in milliseconds |
Request Example
curl --request GET \
--url 'https://symbol-prices-api.mybroker.dev/aggregated-prices/prices?slot=default&pair=BTCUSDT&type=crypto&interval=1m&skip=0&limit=1000&startTime=1733054445000&endTime=1733691937954' \
--header 'api-key: <your_api_key_here>'
Success Response (200)
[
{
"volume": 0,
"openPrice": 100063.99,
"closePrice": 100058.82,
"highPrice": 100066.66,
"lowPrice": 100058.82,
"time": 1733688300000
},
{
"volume": 0,
"openPrice": 100058.82,
"closePrice": 100084.01,
"highPrice": 100107.99,
"lowPrice": 100058.82,
"time": 1733688360000
}
]
Response Fields
Field | Type | Description |
---|---|---|
volume | number | Trading volume |
openPrice | number | Opening price of the asset |
closePrice | number | Closing price of the asset |
highPrice | number | Highest price recorded |
lowPrice | number | Lowest price recorded |
time | integer | Timestamp in milliseconds |
Possible Errors
Status Code | Message | Description |
---|---|---|
401 | Unauthorized | API Key is missing or invalid |
404 | Not Found | Trading pair not found |
500 | Internal Server Error | Unexpected server error |
Usage Example
To fetch aggregated prices using curl
:
curl -X GET "https://symbol-prices-api.mybroker.dev/aggregated-prices/prices?slot=default&pair=BTCUSDT&type=crypto&interval=1m&skip=0&limit=1000&startTime=1733054445000&endTime=1733691937954" \
-H "api-key: <your_api_key_here>"
Using TypeScript with fetch
:
async function fetchAggregatedPrices(apiKey: string): Promise<void> {
try {
const response = await fetch("https://symbol-prices-api.mybroker.dev/aggregated-prices/prices?slot=default&pair=BTCUSDT&type=crypto&interval=1m&skip=0&limit=1000&startTime=1733054445000&endTime=1733691937954", {
method: "GET",
headers: {
"api-key": apiKey
}
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
console.log("Aggregated Prices:", data);
} catch (error) {
console.error("Error fetching aggregated prices:", error);
}
}
// Usage example:
fetchAggregatedPrices("<your_api_key_here>");