A distributed price API service that provides real-time and historical cryptocurrency price data through RPC endpoints.
The API exposes the following RPC endpoints:
Simple health check endpoint that increments the provided nonce.
Request:
{
"nonce": number
}Response:
{
"nonce": number
}Retrieves the latest prices for specified trading pairs.
Request:
{
"pairs": string[]
}Response:
{
"prices": {
"BTCUSDT": {
"tickers": [
{
"exchange": string,
"price": number
}
],
"avg": number
}
}
}Retrieves historical price data for specified trading pairs within a time range.
Request:
{
"pairs": string[],
"from": number, // Seq
"to": number // Seq
}Response:
{
"prices": {
"BTCUSDT": [
{
"timestamp": number,
"value": {
"tickers": [
{
"exchange": string,
"price": number
}
],
"avg": number
}
}
]
}
}Triggers the price pipeline job to update price data. No payload required
Response:
{
"success": boolean,
"error": string // Only present if success is false
}All endpoints return a standard error response format when an error occurs:
{
"success": false,
"error": "Error message"
}BOOTSTRAP_HOST: Bootstrap node host (default: "127.0.0.1")BOOTSTRAP_PORT: Bootstrap node port (default: 30001)DHT_PORT: DHT network port (default: 40001)
- Trading pairs should be provided in the format "BTC/USD" and will be internally converted to "BTCUSD"
- All price values are returned as numbers with appropriate decimal places
- The API uses a distributed hash table (DHT) for peer discovery and communication
Added sample client providing light demo of functionality. Relies on the same .env + SERVER_PUB_KEY env variable
- Current implementation misses:
-
- Data issues handling from Coingecko
-
- Stores market fields with tickers wheres id would be enough and markets themselves could be stored separately
-
- RPC query validation
-
- Better storage management
-
- RPC client implementation with proper CLI
-
- Smarter way for scheduling, current implementation ignores
ttlwhich is taken fromcoingeckoAPI docs and should be used for caching or iteration planning
- Smarter way for scheduling, current implementation ignores
- Nice to have:
-
- Progress tracking
-
- Authorization and throttler which would allow to run service not only locally
-
- Scalability improvements
-
- Tests