Version: 1.0
Base URL: http://localhost:8000/v1 (development)
The Cryptobro API provides endpoints for retrieving cryptocurrency data from CoinGecko. All endpoints return JSON responses and implement caching to minimize external API calls.
Currently, no authentication is required for API access.
All API responses follow a consistent structure:
{
"success": true,
"data": {...},
"count": 10 // Optional: included in list endpoints
}{
"success": false,
"message": "Error description",
"error": "Detailed error message (debug mode only)"
}Check if the API is running and responsive.
Endpoint: GET /v1/health
Response:
{
"status": "ok",
"timestamp": "2024-01-15T10:30:00.000000Z"
}Status Codes:
200 OK- Service is healthy
Retrieve the top 10 cryptocurrencies by market capitalization.
Endpoint: GET /v1/coins/markets
Caching: 60 seconds
Response:
{
"success": true,
"data": [
{
"id": "bitcoin",
"symbol": "btc",
"name": "Bitcoin",
"image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png",
"current_price": 45000.50,
"market_cap": 880000000000,
"market_cap_rank": 1,
"total_volume": 25000000000,
"high_24h": 46000.00,
"low_24h": 44000.00,
"price_change_24h": 500.50,
"price_change_percentage_24h": 1.12,
"circulating_supply": 19000000,
"total_supply": 21000000,
"ath": 69000.00,
"ath_change_percentage": -34.78,
"ath_date": "2021-11-10T14:24:11.849Z",
"atl": 67.81,
"atl_change_percentage": 66000.00,
"atl_date": "2013-07-06T00:00:00.000Z",
"last_updated": "2024-01-15T10:30:00.000Z"
}
// ... 9 more coins
],
"count": 10
}Status Codes:
200 OK- Success500 Internal Server Error- Failed to fetch data
Search for cryptocurrencies by name or symbol.
Endpoint: GET /v1/coins/search
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| q | string | Yes | Search keyword (name or symbol) |
Example Request:
GET /v1/coins/search?q=bitcoin
Caching: 300 seconds (5 minutes)
Response:
{
"success": true,
"data": [
{
"id": "bitcoin",
"symbol": "btc",
"name": "Bitcoin",
"image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png",
"current_price": 45000.50,
"market_cap": 880000000000,
"market_cap_rank": 1,
"price_change_percentage_24h": 1.12
// ... additional fields
},
{
"id": "bitcoin-cash",
"symbol": "bch",
"name": "Bitcoin Cash",
// ... additional fields
}
],
"count": 2,
"query": "bitcoin"
}Status Codes:
200 OK- Success (even if no results found)422 Unprocessable Entity- Missing or invalid query parameter500 Internal Server Error- Failed to fetch data
Error Example (Missing Query):
{
"success": false,
"message": "Search query parameter \"q\" is required",
"data": []
}Get detailed information for a specific cryptocurrency by its symbol.
Endpoint: GET /v1/coins/{symbol}
Path Parameters:
| Parameter | Type | Description |
|---|---|---|
| symbol | string | Cryptocurrency symbol (e.g., btc, eth) |
Example Request:
GET /v1/coins/btc
Caching: 60 seconds per coin
Response:
{
"success": true,
"data": {
"id": "bitcoin",
"symbol": "btc",
"name": "Bitcoin",
"description": {
"en": "Bitcoin is the first successful internet money..."
},
"image": {
"thumb": "https://assets.coingecko.com/coins/images/1/thumb/bitcoin.png",
"small": "https://assets.coingecko.com/coins/images/1/small/bitcoin.png",
"large": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png"
},
"market_cap_rank": 1,
"market_data": {
"current_price": {
"usd": 45000.50
},
"market_cap": {
"usd": 880000000000
},
"total_volume": {
"usd": 25000000000
},
"high_24h": {
"usd": 46000.00
},
"low_24h": {
"usd": 44000.00
},
"price_change_24h": 500.50,
"price_change_percentage_24h": 1.12,
"market_cap_change_24h": 5000000000,
"market_cap_change_percentage_24h": 0.57,
"circulating_supply": 19000000,
"total_supply": 21000000,
"max_supply": 21000000,
"ath": {
"usd": 69000.00
},
"ath_change_percentage": {
"usd": -34.78
},
"ath_date": {
"usd": "2021-11-10T14:24:11.849Z"
},
"atl": {
"usd": 67.81
},
"atl_change_percentage": {
"usd": 66000.00
},
"atl_date": {
"usd": "2013-07-06T00:00:00.000Z"
}
},
"last_updated": "2024-01-15T10:30:00.000Z"
}
}Status Codes:
200 OK- Success404 Not Found- Cryptocurrency with specified symbol not found500 Internal Server Error- Failed to fetch data
Error Example (Not Found):
{
"success": false,
"message": "Cryptocurrency with symbol 'xyz' not found"
}The API implements caching to minimize external API calls to CoinGecko:
- Top coins: Cached for 60 seconds
- Coin search: Cached for 300 seconds (5 minutes)
- Individual coin details: Cached for 60 seconds per coin
No explicit rate limiting is currently enforced on the API endpoints.
| Status Code | Description |
|---|---|
| 200 | Success |
| 404 | Resource not found |
| 422 | Unprocessable entity (validation error) |
| 500 | Internal server error |
success: Alwaysfalsefor error responsesmessage: Human-readable error messageerror: Detailed error information (only in debug mode)
Get top cryptocurrencies:
curl http://localhost:8000/v1/coins/marketsSearch for a cryptocurrency:
curl "http://localhost:8000/v1/coins/search?q=ethereum"Get Bitcoin details:
curl http://localhost:8000/v1/coins/btc// Get top cryptocurrencies
fetch('http://localhost:8000/v1/coins/markets')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Search for cryptocurrencies
fetch('http://localhost:8000/v1/coins/search?q=doge')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Get coin details
fetch('http://localhost:8000/v1/coins/eth')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));All cryptocurrency data is sourced from CoinGecko API (free tier).
- All prices are in USD
- Timestamps are in ISO 8601 format (UTC)
- Symbol matching is case-insensitive (BTC, btc, Btc all work)
- Search is performed on both name and symbol fields
- The API returns the first matching coin when multiple coins share the same symbol