Token Price API Reference
This document provides detailed information about the Token Price API endpoints, which are designed for synchronizing cryptocurrency token price data between external sources and the BlockBet platform.
Authentication​
All endpoints in the Token Price API require:
- Valid API key in the request header
- Specific roles depending on the endpoint:
- CLOUD_SCHEDULES role for job-related operations
- CLOUD_TASKS role for task-related operations
Endpoints​
Token Price Jobs​
Sync Token Price​
Triggers a job to synchronize current token prices for all tokens with valid Coingecko IDs.
POST /token-price-jobs/sync-token-price
Authentication Requirements​
- API Key
- CLOUD_SCHEDULES role
Response​
{
"status": "success"
}
Error Responses​
401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_SCHEDULES role
Sync Token Historical Price​
Triggers a job to synchronize historical token prices for all tokens with valid Coingecko IDs.
POST /token-price-jobs/sync-token-historical-price
Authentication Requirements​
- API Key
- CLOUD_SCHEDULES role
Response​
{
"status": "success"
}
Error Responses​
401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_SCHEDULES role
Token Price Tasks​
Update Token Price​
Updates the current price and related data for a specific token.
POST /token-price-tasks/update-token-price/:tokenId/:fiatCurrency
URL Parameters​
Parameter | Type | Description |
---|---|---|
tokenId | string | The ID of the token to update |
fiatCurrency | string | The fiat currency for price data |
Authentication Requirements​
- API Key
- CLOUD_TASKS role
Response​
{
"status": "success"
}
Error Responses​
400 Bad Request
: When token price data is not found401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_TASKS role
Update Token Price Volume Change​
Updates the 24-hour volume change data for a specific token.
POST /token-price-tasks/update-token-price-volume-change/:tokenId/:fiatCurrency
URL Parameters​
Parameter | Type | Description |
---|---|---|
tokenId | string | The ID of the token to update |
fiatCurrency | string | The fiat currency for price data |
Authentication Requirements​
- API Key
- CLOUD_TASKS role
Response​
{
"status": "success"
}
Error Responses​
400 Bad Request
: When token price data is not found401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_TASKS role
Update Token Historical Price​
Updates historical price data for a specific token over a specified time period.
POST /token-price-tasks/update-token-historical-price/:tokenId/:fiatCurrency/:days
URL Parameters​
Parameter | Type | Description |
---|---|---|
tokenId | string | The ID of the token to update |
fiatCurrency | string | The fiat currency for price data |
days | string | Time period: 'day', 'week', 'month', or 'year' |
Authentication Requirements​
- API Key
- CLOUD_TASKS role
Response​
{
"status": "success"
}
Error Responses​
400 Bad Request
: When token historical data is not found or days is invalid401 Unauthorized
: When the API key is invalid or missing403 Forbidden
: When the request doesn't have the required CLOUD_TASKS role
Operational Considerations​
Rate Limiting​
These endpoints create tasks with specific scheduling to avoid rate limits:
- Token price tasks are scheduled with 5-second intervals
- Historical price tasks are scheduled with 20-second intervals
Processing Flow​
The Token Price API implements a task-based approach:
- Job Endpoints: Create multiple tasks for batch processing
- Task Endpoints: Process individual token updates
- Follow-up Tasks: Some tasks create additional tasks for related data
Supported Fiat Currencies​
The API supports multiple fiat currencies as defined in the FiatCurrency enum:
- USD (US Dollar)
- EUR (Euro)
- GBP (British Pound)
- And other supported currencies
Historical Time Periods​
Historical data is available for multiple time periods:
- Day (1 day)
- Week (7 days)
- Month (30 days)
- Year (365 days)
Security Considerations​
- API Key Protection: Keep your API key secure and don't expose it in client-side code
- Role Assignment: Ensure that only appropriate services have the required roles
- Access Control: These endpoints should only be accessed by authorized internal systems