initial, step 2 already
This commit is contained in:
79
apps/api/README.md
Normal file
79
apps/api/README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# 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)
|
||||
|
||||
```bash
|
||||
poetry run uvicorn apps.api.main:app --reload
|
||||
```
|
||||
|
||||
### Production Mode
|
||||
|
||||
```bash
|
||||
poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
### Using Python directly
|
||||
|
||||
```bash
|
||||
poetry run python -m apps.api.main
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### `GET /health`
|
||||
|
||||
Health check endpoint.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "ok"
|
||||
}
|
||||
```
|
||||
|
||||
### `GET /spec`
|
||||
|
||||
Returns supported capabilities and their versions.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"capabilities": {
|
||||
"light": "light@1.2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Interactive Documentation
|
||||
|
||||
Once the server is running, visit:
|
||||
- **Swagger UI**: http://localhost:8000/docs
|
||||
- **ReDoc**: http://localhost:8000/redoc
|
||||
- **OpenAPI Schema**: http://localhost:8000/openapi.json
|
||||
|
||||
## CORS Configuration
|
||||
|
||||
The API is configured to accept requests from the following origins:
|
||||
- http://localhost:3000
|
||||
- http://localhost:5173
|
||||
- http://localhost:8080
|
||||
- http://127.0.0.1:3000
|
||||
- http://127.0.0.1:5173
|
||||
- http://127.0.0.1:8080
|
||||
|
||||
## Dependencies
|
||||
|
||||
- **FastAPI**: Modern, fast web framework
|
||||
- **Uvicorn**: ASGI server
|
||||
- **Pydantic**: Data validation using Python type hints
|
||||
Reference in New Issue
Block a user