
* 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)
40 lines
910 B
Python
40 lines
910 B
Python
from pydantic import BaseModel, Field
|
|
from typing import List, Optional
|
|
|
|
|
|
class MarketBase(BaseModel):
|
|
exchangeId: str
|
|
rank: Optional[str] = None
|
|
baseSymbol: str
|
|
baseId: str
|
|
quoteSymbol: str
|
|
quoteId: str
|
|
priceQuote: Optional[str] = None
|
|
priceUsd: Optional[str] = None
|
|
volumeUsd24Hr: Optional[str] = None
|
|
percentExchangeVolume: Optional[str] = None
|
|
tradesCount24Hr: Optional[str] = None
|
|
updated: Optional[int] = None
|
|
|
|
|
|
class Market(MarketBase):
|
|
"""Data model for retrieving markets"""
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class MarketCreate(MarketBase):
|
|
"""Data model for creating markets"""
|
|
pass
|
|
|
|
|
|
class MarketResponse(BaseModel):
|
|
"""Response model for market endpoints"""
|
|
timestamp: int
|
|
data: Market
|
|
|
|
|
|
class MarketsResponse(BaseModel):
|
|
"""Response model for multiple markets"""
|
|
timestamp: int
|
|
data: List[Market] |