cd /home/runner/work/LFS-Ayats/LFS-Ayats
uvicorn src.api.main:app --reload --host 0.0.0.0 --port 8000
uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --workers 4
Once the server is running:
# Health check
curl http://localhost:8000/api/v1/health
# System status
curl http://localhost:8000/api/v1/status
# List sessions
curl http://localhost:8000/api/v1/sessions
# Create a session
curl -X POST http://localhost:8000/api/v1/sessions \
-H "Content-Type: application/json" \
-d '{"circuit":"Blackwood GP","vehicle":"XF GTI","driver":"TestDriver"}'
Run the example client to see the API in action:
python examples/api_client_example.py
Test WebSocket telemetry streaming with Python:
import asyncio
import websockets
import json
async def test_websocket():
uri = "ws://localhost:8000/api/v1/telemetry/live"
async with websockets.connect(uri) as websocket:
for i in range(10): # Receive 10 messages
message = await websocket.recv()
data = json.loads(message)
print(f"Speed: {data['data']['speed']:.1f} km/h")
asyncio.run(test_websocket())
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/health |
Health check |
| GET | /api/v1/status |
System status |
| GET | /api/v1/sessions |
List sessions |
| POST | /api/v1/sessions |
Create session |
| GET | /api/v1/sessions/{id} |
Get session |
| DELETE | /api/v1/sessions/{id} |
Delete session |
| GET | /api/v1/{lap_id} |
Get lap details |
| GET | /api/v1/{lap_id}/telemetry |
Get lap telemetry |
| GET | /api/v1/compare?lap_ids=1&lap_ids=2 |
Compare laps |
| WS | /api/v1/telemetry/live |
Live telemetry stream |
| GET | /api/v1/stats/best-laps |
Best laps |
| GET | /api/v1/stats/driver/{name} |
Driver statistics |
| GET | /api/v1/export/csv/{lap_id} |
Export lap as CSV |
See docs/api_documentation.md for complete API reference with all endpoints, parameters, and response formats.
# Run all API tests
pytest tests/unit/api/ tests/integration/api/ -v
# Run with coverage
pytest tests/unit/api/ tests/integration/api/ --cov=src/api --cov-report=html
lsof -i :8000uvicorn src.api.main:app --port 8001curl http://localhost:8000/api/v1/healthws:// not http://✅ 40+ REST endpoints covering all system functionality
✅ WebSocket streaming for real-time telemetry data
✅ Automatic documentation with Swagger UI and ReDoc
✅ Request validation using Pydantic models
✅ CORS support for cross-origin requests
✅ Comprehensive testing with 41 passing tests
✅ Error handling with proper HTTP status codes
✅ Pagination for large datasets
✅ File exports in CSV and JSON formats
Enjoy using the LFS-Ayats REST API! 🚀