Files
home-automation/apps/api
..
2025-10-31 14:25:12 +01:00
2025-11-06 13:39:42 +01:00
2025-11-06 13:39:42 +01:00
2025-10-31 14:25:12 +01:00
2025-11-06 13:39:42 +01:00

Home Automation API

FastAPI-based REST API for the home automation system.

Features

  • Health Check: Monitor API availability
  • Capabilities Specification: Discover supported capabilities and versions
  • CORS Support: Configured for local frontend development
  • Auto-generated Documentation: Interactive API docs via Swagger UI

Running the API

Development Mode (with auto-reload)

poetry run uvicorn apps.api.main:app --reload

Production Mode

poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000

Using Python directly

poetry run python -m apps.api.main

API Endpoints

GET /health

Health check endpoint.

Response:

{
  "status": "ok"
}

GET /spec

Returns supported capabilities and their versions.

Response:

{
  "capabilities": {
    "light": "light@1.2.0"
  }
}

Interactive Documentation

Once the server is running, visit:

CORS Configuration

The API is configured to accept requests from the following origins:

Dependencies

  • FastAPI: Modern, fast web framework
  • Uvicorn: ASGI server
  • Pydantic: Data validation using Python type hints