A modular, extensible FastAPI framework for building production-ready REST APIs with minimal code.
Apiary is a FastAPI framework that combines the power of FastAPI with a unique configuration-driven endpoint system. Build APIs quickly with built-in authentication, rate limiting, metrics, health checks, and more.
- Configuration-driven endpoints - add endpoints without code changes
- Service-based architecture with dependency injection
- Plugin system for custom services
- API key authentication with flexible authorization
- Security headers middleware
- CORS support for cross-origin requests
- Input sanitization and validation
# Clone the repository
git clone https://github.com/lancereinsmith/apiary.git
cd apiary
# Install dependencies (requires uv)
uv sync
# Create configuration
uv run apiary init
# Run the application
uv run apiary serve --reload
# Or using uvicorn directly
uvicorn app:api --reloadGo to http://localhost:8000/docs for interactive API documentation. (Can be disabled.)
Apiary includes a CLI for common tasks:
uv run apiary init # Initialize config files
uv run apiary serve --reload # Dev server with auto-reload
uv run apiary validate-config # Validate API key config
uv run apiary clean # Clean up generated files- Installation - Get started
- Quick Start - Build your first API
- User Guide - Learn all features
- API Reference - Technical docs
Add new API endpoints without writing code - just edit a JSON configuration file:
{
"endpoints": [
{
"path": "/api/crypto",
"method": "GET",
"service": "crypto",
"enabled": true,
"requires_auth": false,
"description": "Get cryptocurrency price data"
}
]
}Create reusable services that can be called by multiple endpoints:
from core.services.base import BaseService
class MyService(BaseService):
async def call(self, parameters=None):
# Your business logic here
return {"result": "data"}Register the service and use it in configurable endpoints or code-based routes.
apiary/
├── config/ # Configuration management
├── core/ # Core utilities (auth, middleware, etc.)
├── routers/ # API route handlers
├── services/ # Business logic services
├── models/ # Request/response models
├── templates/ # HTML templates
├── static/ # Static files
├── app.py # FastAPI application factory
└── cli.py # CLI commands
GET /- Landing page (can disable inconfig/settings.json)GET /health- Health checkGET /health/live- Liveness probeGET /health/ready- Readiness probeGET /metrics- Application metricsGET /endpoints- Endpoint discoveryGET /auth/status- Authentication statusPOST /auth/validate- Validate API key
Apiary is perfect for:
- Personal APIs - Quickly build APIs for personal projects
- Microservices - Create modular, maintainable microservices
- API Gateways - Build custom API gateways with routing and aggregation
-
Create service in
services/weather_service.py:from core.services.base import BaseService class WeatherService(BaseService): async def call(self, parameters=None): city = parameters.get("city", "London") # Fetch weather data... return {"city": city, "temp": 20}
-
Register service in
services/__init__.py:from services.weather_service import WeatherService # Services are auto-discovered and registered by class name
-
Add endpoint in
config/endpoints.json:{ "path": "/api/weather", "method": "GET", "service": "weather", "enabled": true, "requires_auth": false }
That's it! Restart the server and your endpoint is live.
{
"api_keys": "your-api-key-1,your-api-key-2",
"enable_landing_page": true,
"enable_docs": true,
"enable_redoc": true,
"enable_openapi": true,
"enabled_routers": ["health", "metrics", "auth", "endpoints"],
"rate_limit_enabled": true,
"rate_limit_per_minute": 60,
"rate_limit_per_minute_authenticated": 300
}Tip: API keys can also be file paths (e.g., "config/api_keys.txt") for easier management.
{
"endpoints": [
{
"path": "/api/example",
"method": "GET",
"service": "example",
"enabled": true,
"requires_auth": false,
"description": "Example endpoint"
}
]
}# On your server
git clone https://github.com/lancereinsmith/apiary.git
cd apiary
uv sync
# Initialize configuration
uv run apiary init
# Edit config/settings.json with production values
# Set up nginx (see _server/nginx/)
# Set up systemd (see _server/systemd/)
# Enable SSL with Let's Encrypt
sudo systemctl enable apiary
sudo systemctl start apiaryApiary is designed for update-safe deployments. Config and custom code are gitignored:
cd /path/to/apiary
git pull origin main # Your config and custom code won't be touched!
uv sync # Update dependencies
sudo systemctl restart apiary- Config:
config/settings.json,config/endpoints.json, API key files - Custom code: put services in
services_custom/and routers inrouters_custom/(created byuv run apiary init) so they are never overwritten bygit pull
See the Deployment Guide for detailed instructions.
Contributions are welcome! Please feel free to submit a Pull Request.
See the Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with FastAPI
- Documentation powered by MkDocs Material
- Documentation: Read the docs
- Issues: GitHub Issues
If you find Apiary useful, please consider giving it a star on GitHub!
