/** * API utilities for fetching celestial data */ import axios from 'axios'; import type { CelestialDataResponse, BodyInfo } from '../types'; const API_BASE_URL = 'http://localhost:8000/api'; export const api = axios.create({ baseURL: API_BASE_URL, timeout: 30000, }); /** * Fetch celestial positions */ export async function fetchCelestialPositions( startTime?: string, endTime?: string, step: string = '1d' ): Promise { const params: Record = { step }; if (startTime) params.start_time = startTime; if (endTime) params.end_time = endTime; const response = await api.get('/celestial/positions', { params, }); return response.data; } /** * Fetch body information */ export async function fetchBodyInfo(bodyId: string): Promise { const response = await api.get(`/celestial/info/${bodyId}`); return response.data; } /** * List all bodies */ export async function fetchAllBodies(): Promise<{ bodies: BodyInfo[] }> { const response = await api.get('/celestial/list'); return response.data; }