Cryptocurrency Data Service
A FastAPI backend service that provides cryptocurrency market data by integrating with the CoinCap API v3.
Features
- Real-time Cryptocurrency Data: Access comprehensive data for thousands of cryptocurrencies
- Market Information: Detailed exchange and trading pair data
- Historical Prices: Access historical price data with various time intervals
- Conversion Rates: Get current conversion rates between cryptocurrencies and fiat currencies
- Data Persistence: Local SQLite database for caching and quick retrieval
- Health Monitoring: Built-in health check endpoint
Tech Stack
- FastAPI: Modern, high-performance web framework
- SQLAlchemy: SQL toolkit and ORM
- Alembic: Database migration tool
- SQLite: Lightweight relational database
- HTTPX: Asynchronous HTTP client
- Pydantic: Data validation and settings management
- Uvicorn: ASGI server
API Endpoints
The service provides the following API endpoints:
Health Check
GET /health
: Check the health status of the service and its dependencies
Assets
GET /api/assets
: Get a list of cryptocurrency assets with optional filtering and paginationGET /api/assets/{slug}
: Get detailed information about a specific assetGET /api/assets/{slug}/markets
: Get market information for a specific assetGET /api/assets/{slug}/history
: Get historical price data for a specific asset
Exchanges
GET /api/exchanges
: Get a list of exchanges with optional paginationGET /api/exchanges/{exchange_id}
: Get detailed information about a specific exchange
Markets
GET /api/markets
: Get a list of markets with optional filtering and pagination
Rates
GET /api/rates
: Get a list of conversion ratesGET /api/rates/{slug}
: Get a specific conversion rate
Installation and Setup
Prerequisites
- Python 3.8 or higher
Installation
-
Clone the repository:
git clone <repository-url> cd cryptocurrency-data-service
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables (optional):
# Create a .env file COINCAP_API_KEY=your_api_key COINCAP_API_BASE_URL=https://rest.coincap.io/v3
-
Run database migrations:
alembic upgrade head
Running the Application
Start the server with:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
Once the server is running, you can access the API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Data Sources
This service uses the CoinCap API v3 to provide cryptocurrency data. The API key is required for production use.
License
Description
Languages
Python
98.7%
Mako
1.3%