Automated Action 3a29a346a9 Initial implementation of cryptocurrency data API service using CoinCap API
* 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)
2025-05-14 12:18:27 +00:00

64 lines
1.4 KiB
Python

from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime
class AssetBase(BaseModel):
id: str
rank: str
symbol: str
name: str
supply: str
max_supply: Optional[str] = None
market_cap_usd: str
volume_usd_24hr: str
price_usd: str
change_percent_24hr: Optional[str] = None
vwap_24hr: Optional[str] = None
explorer: Optional[str] = None
class Asset(AssetBase):
"""Data model for retrieving assets"""
class Config:
from_attributes = True
class AssetCreate(AssetBase):
"""Data model for creating assets"""
pass
class AssetPriceHistoryBase(BaseModel):
price_usd: str
time: int
date: str
class AssetPriceHistory(AssetPriceHistoryBase):
"""Data model for retrieving asset price history"""
class Config:
from_attributes = True
class AssetPriceHistoryCreate(AssetPriceHistoryBase):
"""Data model for creating asset price history"""
asset_id: str
class AssetResponse(BaseModel):
"""Response model for asset endpoints"""
timestamp: int
data: Asset
class AssetsResponse(BaseModel):
"""Response model for multiple assets"""
timestamp: int
data: List[Asset]
class AssetHistoryResponse(BaseModel):
"""Response model for asset history endpoint"""
timestamp: int
data: List[AssetPriceHistory]