107 lines
2.8 KiB
Markdown
107 lines
2.8 KiB
Markdown
# 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 pagination
|
|
- `GET /api/assets/{slug}`: Get detailed information about a specific asset
|
|
- `GET /api/assets/{slug}/markets`: Get market information for a specific asset
|
|
- `GET /api/assets/{slug}/history`: Get historical price data for a specific asset
|
|
|
|
### Exchanges
|
|
|
|
- `GET /api/exchanges`: Get a list of exchanges with optional pagination
|
|
- `GET /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 rates
|
|
- `GET /api/rates/{slug}`: Get a specific conversion rate
|
|
|
|
## Installation and Setup
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd cryptocurrency-data-service
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Set up environment variables (optional):
|
|
```bash
|
|
# Create a .env file
|
|
COINCAP_API_KEY=your_api_key
|
|
COINCAP_API_BASE_URL=https://rest.coincap.io/v3
|
|
```
|
|
|
|
4. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
### Running the Application
|
|
|
|
Start the server with:
|
|
|
|
```bash
|
|
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](https://rest.coincap.io/v3) to provide cryptocurrency data. The API key is required for production use.
|
|
|
|
## License
|
|
|
|
[MIT](LICENSE) |