
* Created FastAPI application structure * Added database models for assets, exchanges, markets, and rates * Integrated with CoinCap API * Implemented REST API endpoints * Setup SQLite persistence with Alembic migrations * Added comprehensive documentation Generated with BackendIM... (backend.im)
2.5 KiB
2.5 KiB
Cryptocurrency Data API Service
A FastAPI backend service that provides cryptocurrency data via CoinCap API. This service acts as a wrapper around the CoinCap API, providing additional features like data caching, persistence, and a clean REST API.
Features
- RESTful API for accessing cryptocurrency data
- Proxies CoinCap API to provide cryptocurrency market data
- Data models for assets, exchanges, markets, and conversion rates
- Persistent storage using SQLite
- Database migrations using Alembic
- OpenAPI documentation
API Endpoints
The API provides the following endpoints:
Health Check
GET /health
- Check if the service is up and running
Assets
GET /api/v1/assets
- Get a list of assets with optional filteringGET /api/v1/assets/{asset_id}
- Get details for a specific assetGET /api/v1/assets/{asset_id}/markets
- Get markets for a specific assetGET /api/v1/assets/{asset_id}/history
- Get historical data for a specific asset
Exchanges
GET /api/v1/exchanges
- Get a list of exchangesGET /api/v1/exchanges/{exchange_id}
- Get details for a specific exchange
Markets
GET /api/v1/markets
- Get a list of markets with optional filtering
Rates
GET /api/v1/rates
- Get conversion ratesGET /api/v1/rates/{rate_id}
- Get a specific conversion rate
Prerequisites
- Python 3.8 or higher
- SQLite
Installation
-
Clone the repository:
git clone <repository-url> cd cryptocurrency-data-api-service
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
alembic upgrade head
Usage
Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
After starting the server, you can access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Environment Variables
The following environment variables can be configured:
COINCAP_API_KEY
- Your CoinCap API key (default is provided for development)DB_PATH
- Path to SQLite database file (default:/app/storage/db/db.sqlite
)
License
Credits
- FastAPI - Web framework for building APIs
- CoinCap API - Cryptocurrency data provider