/** * API client for TradingAgents backend */ import axios from "axios"; import type { AnalysisRequest, AnalysisResponse, ConfigResponse, HealthResponse, Ticker, } from "./types"; const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000"; const apiClient = axios.create({ baseURL: API_URL, headers: { "Content-Type": "application/json", }, }); export const api = { /** * Get API health status */ async health(): Promise { const response = await apiClient.get("/api/health"); return response.data; }, /** * Get configuration options */ async getConfig(): Promise { const response = await apiClient.get("/api/config"); return response.data; }, /** * Run trading analysis */ async runAnalysis(request: AnalysisRequest): Promise { const response = await apiClient.post( "/api/analyze", request ); return response.data; }, /** * Get list of popular tickers */ async getTickers(): Promise<{ tickers: Ticker[] }> { const response = await apiClient.get<{ tickers: Ticker[] }>("/api/tickers"); return response.data; }, };