APIFromAnything Documentation๏ƒ

APIFromAnything
Transform any Python function into a production-ready REST API endpoint in seconds

Welcome to the official documentation for APIFromAnything, a powerful Python library designed to transform ordinary Python functions into fully-functional REST API endpoints using a decorator-based approach.

Version 1.0.0 - Production Ready๏ƒ

APIFromAnything is now production-ready with version 1.0.0! This release includes:

  • Comprehensive test suite with high code coverage

  • Production-grade security features

  • Performance optimizations for high-traffic scenarios

  • Detailed documentation and examples

  • Support for multiple deployment environments

  • Full async/await support throughout the codebase

Overview๏ƒ

APIFromAnything is designed to be robust, extensible, and high-performance, with features like automatic routing, input validation, output serialization, error handling, and documentation generation. Itโ€™s perfect for quickly creating APIs from existing code, building microservices, or developing serverless functions.

from apifrom import API, api

app = API(title="My API")

@api(route="/hello/{name}")
def hello(name: str, greeting: str = "Hello") -> dict:
    """Say hello to someone."""
    return {"message": f"{greeting}, {name}!"}

# That's it! You now have a fully functioning API endpoint

Key Features๏ƒ

  • ๐Ÿงฉ Simple Decorator API: Transform any Python function into an API endpoint with a single decorator

  • ๐Ÿ” Type-Based Validation: Automatic request validation based on Python type hints

  • ๐Ÿ”„ Automatic Serialization: Convert Python objects to JSON responses automatically

  • ๐Ÿ›ฃ๏ธ Path & Query Parameters: Support for path and query parameters with automatic type conversion

  • โšก Asynchronous Support: First-class support for async/await functions

  • ๐Ÿ”Œ Middleware System: Extensible middleware system for request/response processing

  • ๐Ÿ”’ Security Features: Built-in support for JWT, API key, Basic auth, OAuth2, CORS, CSRF, security headers, and more

  • ๐Ÿ“š OpenAPI Documentation: Automatic generation of OpenAPI/Swagger documentation

  • ๐Ÿ“Š Monitoring & Metrics: Track API performance and usage with comprehensive metrics collection

  • ๐Ÿš€ Performance Optimization: Tools for profiling, caching, connection pooling, and batch processing

  • โ˜๏ธ Serverless Ready: Deploy to AWS Lambda, Google Cloud Functions, Azure Functions, Vercel, and Netlify

  • ๐Ÿ”Œ Plugin System: Extend and customize functionality with a powerful plugin architecture

Documentation Structure๏ƒ

This documentation is organized into the following sections:

Installation๏ƒ

# Basic installation
pip install apifrom

# With all optional dependencies
pip install "apifrom[all]"

License๏ƒ

APIFromAnything is licensed under the MIT License. See the LICENSE file for details.

Contents: