diff --git a/cryptoai/api/__pycache__/binance_api.cpython-313.pyc b/cryptoai/api/__pycache__/binance_api.cpython-313.pyc index bcc4f5e..6e81221 100644 Binary files a/cryptoai/api/__pycache__/binance_api.cpython-313.pyc and b/cryptoai/api/__pycache__/binance_api.cpython-313.pyc differ diff --git a/cryptoai/routes/crypto.py b/cryptoai/routes/crypto.py index 6e09d65..6bb1e15 100644 --- a/cryptoai/routes/crypto.py +++ b/cryptoai/routes/crypto.py @@ -54,4 +54,27 @@ async def get_crypto_kline(symbol: str, timeframe: Optional[str] = None, limit: else: result[timeframe] = binance_api.get_historical_klines(symbol=symbol, interval=timeframe, limit=limit).to_dict(orient="records") + return result + +@router.get("/news") +async def get_crypto_news(session: Session = Depends(get_db)): + + url = 'https://api.blockbeats.cn/h5v1/newsflash/list?page=1&limit=0&ios=1&end_time=&detective=-2' + + response = requests.get(url) + data = response.json() + + result = [] + + for item in data["data"]["list"]: + timestamp = item["add_time"] + add_time = datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S") + result.append({ + "title": item["title"], + "content": item["content"], + "timestamp": timestamp, + "add_time": add_time, + "url" : item["url"] + }) + return result \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f8dab09..0c6daee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: cryptoai-api: build: . container_name: cryptoai-api - image: cryptoai-api:0.2.15 + image: cryptoai-api:0.2.16 restart: always ports: - "8000:8000"