Overview
Exchange management endpoints provide control over which exchanges are active, their configuration, and worker status. These endpoints support dynamic exchange addition, blacklisting, and real-time status monitoring.GET /api/v1/exchanges/config
Retrieve the current exchange configuration for all non-blacklisted exchanges.Request
Response
Returns exchange configuration from the CCXT service. The exact schema depends on the CCXT service implementation but typically includes:List of configured exchange objects
This endpoint caches results in Redis for 1 hour to reduce load on the CCXT service. The cache is automatically invalidated when exchanges are added, removed, or blacklisted.
Example Response
GET /api/v1/exchanges/supported
Get the list of currently supported (non-blacklisted) exchange IDs.Request
Response
Array of exchange IDs currently active in the system
Total number of supported exchanges
Results are cached in Redis for 30 minutes. The cache is invalidated when the exchange configuration changes.
Example Response
GET /api/v1/exchanges/workers/status
Get the status of exchange data collection workers.Request
Response
Error message if collector service unavailable
This endpoint returns worker status from the collector service when available. If the collector service is not initialized, it returns a 503 error.
Example Response
POST /api/v1/exchanges/add/:exchange
Admin Only - Dynamically add and initialize a new exchange.Authentication
RequiresADMIN_API_KEY in the X-Admin-Key header.
Request
Path Parameters
Exchange ID to add (e.g.,
binance, kraken, bybit)Response
Returns the response from the CCXT service indicating success or failure.Side Effects
- Adds the exchange to the CCXT service configuration
- Restarts the collector service to begin data collection
- Invalidates exchange configuration cache
POST /api/v1/exchanges/refresh
Admin Only - Refresh configuration for all non-blacklisted exchanges.Authentication
RequiresADMIN_API_KEY in the X-Admin-Key header.
Request
Response
Returns the refresh response from the CCXT service.Side Effects
- Refreshes exchange metadata from CCXT
- Restarts the collector service to apply changes
- Invalidates all exchange-related caches
Use this endpoint after updating exchange API credentials or when exchanges add new trading pairs or features.
POST /api/v1/exchanges/blacklist/:exchange
Admin Only - Add an exchange to the blacklist to stop data collection.Authentication
RequiresADMIN_API_KEY in the X-Admin-Key header.
Request
Path Parameters
Exchange ID to blacklist (e.g.,
coinbase, kraken)Response
Returns the blacklist response from the CCXT service.Side Effects
- Adds the exchange to the blacklist in CCXT service
- Attempts to restart the exchange worker (non-blocking)
- Invalidates exchange configuration and supported exchanges cache
- Sets
X-Worker-Restart-Warningheader if worker restart fails
Blacklisting an exchange stops all data collection and API calls to that exchange. This is useful when an exchange is experiencing downtime or API issues.
DELETE /api/v1/exchanges/blacklist/:exchange
Admin Only - Remove an exchange from the blacklist to resume data collection.Authentication
RequiresADMIN_API_KEY in the X-Admin-Key header.
Request
Path Parameters
Exchange ID to remove from blacklist
Response
Returns the unblacklist response from the CCXT service.Side Effects
- Removes the exchange from the blacklist
- Attempts to restart the exchange worker to resume collection
- Invalidates exchange configuration cache
- Sets
X-Worker-Restart-Infoheader with restart status
POST /api/v1/exchanges/workers/:exchange/restart
Admin Only - Restart the data collection worker for a specific exchange.Authentication
RequiresADMIN_API_KEY in the X-Admin-Key header.
Request
Path Parameters
Exchange ID for worker restart
Response
Success message
Exchange ID that was restarted
Example Response
Error Responses
- 400 Bad Request: Exchange parameter missing
- 503 Service Unavailable: Collector service not available
- 500 Internal Server Error: Worker restart failed
Exchange Connectivity Checks
All exchange configuration changes trigger automatic connectivity validation:- Health Check: Verifies the exchange API is reachable
- Capability Check: Confirms required endpoints (fetchTickers, fetchOrderBook) are available
- Rate Limit Validation: Ensures API rate limits are configured correctly
- Worker Initialization: Starts or restarts data collection workers
Cache Invalidation Strategy
The exchange handler invalidates caches on configuration changes:- Add/Remove Exchange: Clears
exchange:configandexchange:supportedcaches - Blacklist Change: Clears
exchange:configandexchange:supportedcaches - Refresh: Clears all exchange-related caches
Redis Cache Keys
exchange:config- Full exchange configuration (1 hour TTL)exchange:supported- List of supported exchange IDs (30 minute TTL)
Source Reference
Exchange endpoints are implemented in:- Handler:
services/backend-api/internal/api/handlers/exchange.go:64-375 - Route Registration:
services/backend-api/internal/api/routes.go:1142-1160