Logo

Contents:

  • Welcome to APIFromAnything’s documentation!
    • Quick Links
    • Documentation Sections
  • Indices and tables
  • Getting Started with APIFromAnything
    • Installation
      • Basic Installation
      • Installation with Optional Dependencies
    • Quick Start
      • Creating Your First API
      • Creating an Async API
      • Testing Your API
    • Core Concepts
      • API Instance
      • API Decorator
      • Request and Response
      • Path Parameters
      • Query Parameters
      • Request Body
      • Type Validation
      • Plugin System
    • Middleware
    • Error Handling
    • Next Steps
  • Core Concepts
    • API Class
      • Key Properties
      • Key Methods
    • API Decorator
      • Key Parameters
    • Request and Response
      • Request
      • Response
    • Router
    • Middleware
    • Type Validation
      • Basic Type Validation
      • Advanced Type Validation with Pydantic
    • Asynchronous Support
    • Plugin System
    • Serverless Adapters
    • OpenAPI Documentation
  • πŸ“š API Reference for APIFromAnything
    • 🧩 Core Module
      • API Class
        • Constructor Parameters
        • Methods
      • api Decorator
        • Parameters
      • Request Class
        • Properties
        • Methods
      • Response Class
        • Constructor Parameters
    • Middleware Module
      • Middleware Base Class
        • Methods
      • Built-in Middleware Components
        • CacheMiddleware
        • RateLimitMiddleware
        • CORSMiddleware
    • Security Module
      • JWT Authentication
      • API Key Authentication
      • Basic Authentication
    • Performance Module
      • Caching
      • Request Coalescing
      • Batch Processing
      • Web Decorator
    • Exceptions Module
      • Base Exception Classes
        • APIError
      • Common Error Classes
        • BadRequestError
        • NotFoundError
        • UnauthorizedError
        • ForbiddenError
    • Monitoring Module
      • MetricsCollector
      • MetricsMiddleware
      • PrometheusExporter
    • Adapters Module
      • LambdaAdapter
      • VercelAdapter
    • Utility Functions
      • create_jwt_token
      • invalidate_cache
      • get_performance_metrics
    • Constants
      • HTTP Methods
      • Status Codes
    • Plugin System
      • Plugin Class
        • Methods
      • PluginManager Class
        • Methods
      • PluginMetadata Class
        • Constructor Parameters
      • PluginConfig Class
        • Constructor Parameters
        • Methods
      • PluginHook Class
        • Constructor Parameters
        • Methods
      • PluginEvent Enum
        • Values
      • PluginState Enum
        • Values
      • PluginPriority Enum
        • Values
      • Built-in Plugins
        • LoggingPlugin
    • πŸ”„ Async Support
      • Async API Endpoints
      • Async Middleware
      • Async Database Operations
  • API Reference
    • src
    • apifrom
      • Overview
      • Classes
        • API
        • router
        • middleware
        • debug
        • title
        • description
        • version
        • docs_url
        • __call__()
        • _build_app()
        • _get_current_instance()
        • add_middleware()
        • add_route()
        • add_routes()
        • process_request()
        • register_endpoint()
        • run()
        • APIProfiler
        • clear()
        • disable()
        • enable()
        • get_all_reports()
        • get_report()
        • profile_endpoint()
        • save_reports()
        • _generate_cache_key()
        • _get_endpoint_ttl()
        • clear()
        • get_stats()
        • invalidate()
        • process_request()
        • BatchProcessor
        • _get_or_create_collector()
        • force_process()
        • get_all_stats()
        • get_stats()
        • map()
        • process()
        • process_batch()
        • reset_all_stats()
        • reset_stats()
        • wait_for_all_empty()
        • CacheAnalytics
        • get_hot_keys()
        • get_large_keys()
        • print_summary()
        • record_delete()
        • record_error()
        • record_hit()
        • record_miss()
        • record_request()
        • record_set()
        • reset()
        • save()
        • to_dict()
        • to_json()
        • CacheBackend
        • clear()
        • delete()
        • get()
        • get_stats()
        • set()
        • CacheOptimizer
        • auto_tune()
        • delete()
        • get()
        • get_analytics()
        • reset_analytics()
        • set()
        • ConnectionPool
        • _close_connection()
        • _create_connection()
        • _validate_connection()
        • acquire()
        • close()
        • connection()
        • get_metrics()
        • initialize()
        • release()
        • _initialize_database_pool()
        • _initialize_redis_pool()
        • dispatch()
        • get_metrics()
        • initialize()
        • print_metrics()
        • process_request()
        • process_response()
        • shutdown()
        • select_items_to_evict()
        • export()
        • export_to_file()
        • select_items_to_evict()
        • select_items_to_evict()
        • export()
        • export_periodic()
        • _cleanup_if_needed()
        • _evict_if_needed()
        • clear()
        • delete()
        • get()
        • get_stats()
        • set()
        • MetricsCollector
        • create_counter()
        • create_gauge()
        • create_histogram()
        • create_metric()
        • create_summary()
        • get_all_metrics()
        • get_metric()
        • increment()
        • observe()
        • reset()
        • set()
        • start_timer()
        • stop_timer()
        • track_error()
        • track_request()
        • track_request_end()
        • MetricsMiddleware
        • on_error()
        • post_request()
        • pre_request()
        • register()
        • dispatch()
        • process_request()
        • process_response()
        • OptimizationAnalyzer
        • _analyze_profile_reports()
        • _analyze_system_stats()
        • _generate_code_specific_recommendations()
        • _generate_general_recommendations()
        • _get_system_stats()
        • _save_recommendations()
        • analyze()
        • get_optimization_config()
        • get_recommendations()
        • print_summary()
        • set_optimization_config()
        • OptimizationConfig
        • create_aggressive()
        • create_balanced()
        • create_minimal()
        • load()
        • save()
        • to_dict()
        • to_json()
        • OptimizationRecommendation
        • print_summary()
        • save()
        • to_dict()
        • to_json()
        • _auto_tune()
        • _cache_response()
        • _generate_cache_key()
        • _get_from_cache()
        • _is_cacheable()
        • clear_cache()
        • dispatch()
        • get_analytics()
        • get_stats()
        • process_request()
        • process_response()
        • save_analytics()
        • PoolManager
        • close_all()
        • close_pool()
        • create_pool()
        • get_metrics()
        • get_pool()
        • print_summary()
        • clear()
        • disable()
        • dispatch()
        • enable()
        • get_all_reports()
        • get_report()
        • process_request()
        • process_response()
        • ProfileReport
        • get_recommendations()
        • print_summary()
        • save()
        • to_dict()
        • to_json()
        • _format_labels()
        • export()
        • export_to_file()
        • serve_metrics()
        • _make_key()
        • clear()
        • delete()
        • get()
        • get_stats()
        • set()
        • RequestCoalescingMiddleware
        • get_stats()
        • process_request()
        • process_response()
        • select_items_to_evict()
        • select_items_to_evict()
        • Web
        • create_default_web_optimization()
        • get_optimization_config()
        • is_optimized()
        • optimize()
      • Functions
        • api()
        • api_key_required()
        • basic_auth_required()
        • batch_process()
        • coalesce_requests()
        • jwt_required()
        • oauth2_required()
  • Middleware System in APIFromAnything
    • Introduction to Middleware
    • Adding Middleware to Your API
    • Built-in Middleware Components
      • CacheMiddleware
      • RateLimitMiddleware
      • CORSMiddleware
      • SecurityHeadersMiddleware
      • CSRFMiddleware
      • XSSProtectionMiddleware
      • ErrorHandlingMiddleware
      • LoggingMiddleware
      • CompressionMiddleware
      • AuthenticationMiddleware
    • Creating Custom Middleware
      • Middleware with Configuration
      • Middleware with Early Response
    • Middleware Execution Order
    • Middleware Best Practices
      • 1. Keep Middleware Focused
      • 2. Order Middleware Correctly
      • 3. Use Middleware for Cross-Cutting Concerns
      • 4. Make Middleware Configurable
      • 5. Document Middleware
    • Conclusion
  • Security Guide for APIFromAnything
    • Authentication Methods
      • JWT Authentication
        • Generating JWT Tokens
      • API Key Authentication
      • Basic Authentication
      • OAuth2 Authentication
      • Multiple Authentication Methods
    • Security Middleware
      • CORS Middleware
      • CSRF Middleware
      • Security Headers Middleware
      • Rate Limiting Middleware
    • Input Validation
    • SQL Injection Prevention
    • Best Practices
      • 1. Use HTTPS
      • 2. Store Secrets Securely
      • 3. Implement Proper Error Handling
      • 4. Implement Proper Logging
      • 5. Implement Proper Access Control
    • Security Checklist
    • Additional Resources
  • Performance Optimization in APIFromAnything
    • Introduction
    • Async Support in Performance Optimization
    • Web Decorator for Easy Optimization
    • Caching
      • Basic Caching
      • Advanced Caching
      • Cache Invalidation
      • Cache Middleware
    • Request Coalescing
    • Batch Processing
      • Batch Processing Decorator
      • Ad-hoc Batch Operations
    • Connection Pooling
    • Profiling
      • Profiling Decorator
      • Profiling Middleware
      • Accessing Profiling Data
    • Auto-Tuning
    • Asynchronous Programming
    • Performance Best Practices
      • 1. Use Caching
      • 2. Use Asynchronous Programming
      • 3. Use Connection Pooling
      • 4. Use Batch Processing
      • 5. Use Request Coalescing
      • 6. Use Profiling
      • 7. Use Pagination
      • 8. Use Compression
      • 9. Use Database Optimization
      • 10. Use the Web Decorator
    • Performance Monitoring
      • Metrics Collection
      • Available Metrics
    • Conclusion
  • Testing Your APIs
    • Overview
    • Types of Tests
    • Test Client
    • Unit Testing
    • Integration Testing
    • Functional Testing
    • Performance Testing
    • Security Testing
    • Mocking
    • Fixtures
    • Parameterized Tests
    • Test Coverage
    • Continuous Integration
    • Best Practices
    • Testing Async Functions
      • Setting Up Pytest for Async Testing
      • Testing Async API Endpoints
      • Testing Async Middleware
      • Testing Async Database Operations
      • Testing Async HTTP Requests
      • Testing Async Context Managers
      • Testing Async Iterators
      • Testing Timeouts
      • Testing Task Cancellation
      • Testing Async Error Handling
      • Testing Async API with TestClient
      • Testing Async Middleware with AsyncMiddlewareTester
    • Conclusion
  • Deployment Guide for APIFromAnything
    • Table of Contents
    • Docker Deployment {#docker-deployment}
      • 1. Create a Dockerfile
      • 2. Create a requirements.txt file
      • 3. Build the Docker image
      • 4. Run the Docker container
      • 5. Docker Compose (Optional)
    • Kubernetes Deployment {#kubernetes-deployment}
      • 1. Create a Kubernetes Deployment
      • 2. Create a Kubernetes Service
      • 3. Apply the Kubernetes configurations
      • 4. Horizontal Pod Autoscaling (Optional)
    • Serverless Deployment {#serverless-deployment}
      • AWS Lambda {#aws-lambda}
        • 1. Create a Lambda handler
        • 2. Package your application
        • 3. Deploy to AWS Lambda
        • 4. Configure API Gateway
      • Google Cloud Functions {#google-cloud-functions}
        • 1. Create a Cloud Function handler
        • 2. Create a requirements.txt file
        • 3. Deploy to Google Cloud Functions
      • Azure Functions {#azure-functions}
        • 1. Create an Azure Function project
        • 2. Modify the function code
        • 3. Update requirements.txt
        • 4. Deploy to Azure Functions
    • Performance Considerations {#performance-considerations}
      • 1. Asynchronous Processing
      • 2. Caching
      • 3. Connection Pooling
      • 4. Load Testing
    • Monitoring in Production {#monitoring-in-production}
      • 1. Prometheus Integration
      • 2. Logging
      • 3. Alerting
      • 4. Distributed Tracing
    • Production Deployment Checklist
      • Security Checklist
      • Performance Checklist
      • Monitoring Checklist
      • Deployment Environment Checklist
      • Final Checklist
  • Deployment Guide for APIFromAnything
    • Table of Contents
    • Local Development
    • Docker Deployment
      • Dockerfile
      • Docker Compose
      • Building and Running
    • Serverless Deployment
      • AWS Lambda
        • Installation
        • Lambda Handler
        • Serverless Framework Configuration
      • Google Cloud Functions
      • Azure Functions
    • Traditional Server Deployment
      • Gunicorn + Nginx
        • Gunicorn Configuration
        • Nginx Configuration
        • Running with Gunicorn
      • uWSGI + Nginx
        • uWSGI Configuration
        • Running with uWSGI
    • Kubernetes Deployment
      • Kubernetes Deployment YAML
      • Kubernetes Service YAML
      • Deploying to Kubernetes
    • Monitoring and Observability
      • Prometheus Integration
      • Logging Integration
    • Security Considerations
      • HTTPS
      • Environment Variables
      • Rate Limiting
      • Security Headers
  • Serverless Deployment
    • Overview
    • Supported Platforms
    • Async Support in Serverless Environments
    • AWS Lambda
      • Basic Usage
      • Deployment
      • Advanced Configuration
    • Google Cloud Functions
      • Basic Usage
      • Deployment
      • Advanced Configuration
    • Azure Functions
      • Basic Usage
      • Deployment
      • Advanced Configuration
    • Vercel
      • Basic Usage
      • Deployment
      • Advanced Configuration
    • Netlify
      • Basic Usage
      • Deployment
      • Advanced Configuration
    • Best Practices
      • Cold Start Optimization
      • Error Handling
      • Logging
      • Security
    • Conclusion
  • Advanced Caching in APIFromAnything
    • Overview
    • Cache Backends
      • In-Memory Cache
      • Redis Cache
      • Memcached Cache
    • Cache Invalidation Strategies
      • Tag-Based Invalidation
      • Dependency-Based Invalidation
    • Advanced Cache Middleware
    • Cache Control Decorators
      • Cache Decorator
      • No Cache Decorator
      • Invalidate Decorator
    • Advanced Usage Examples
      • Blog API with Dependency-Based Invalidation
      • E-commerce API with Tag-Based Invalidation
    • Performance Considerations
      • Cache Key Generation
      • Cache Invalidation
      • Distributed Caching
    • Best Practices
    • Conclusion
  • πŸ”Œ Plugin System
    • πŸš€ Overview
    • 🧩 Core Components
      • Plugin Base Class
      • Plugin Manager
      • Plugin Metadata
      • Plugin Configuration
    • πŸ”„ Plugin Lifecycle
      • Lifecycle States
    • πŸ”„ Request/Response Hooks
      • Request Processing Flow
    • πŸ“’ Event System
      • Available Events
    • πŸͺ Hook System
      • Hook Priority
    • βš™οΈ Configuration Management
      • Configuration Methods
    • πŸ“¦ Built-in Plugins
      • LoggingPlugin
    • πŸ” Examples
      • Basic Plugin Example
      • Plugin with Dependencies
      • Advanced Plugin Example
    • πŸ† Best Practices
      • Error Handling
      • Resource Management
    • πŸ”— Related Documentation
    • 🀝 Contributing
  • Production Deployment Checklist
    • Code Cleanup
    • Security
    • Performance
    • Configuration
    • Monitoring and Logging
    • Deployment
    • Documentation
    • Testing
    • Final Checks
  • Troubleshooting
    • Installation Issues
      • Package Not Found
      • Dependency Conflicts
    • Runtime Issues
      • Import Errors
      • API Not Starting
      • Route Not Found
      • Validation Errors
      • Authentication Errors
      • CORS Errors
      • Performance Issues
    • Deployment Issues
      • Serverless Deployment Issues
      • Docker Deployment Issues
    • Plugin Issues
      • Plugin Not Loading
      • Plugin Errors
    • Middleware Issues
      • Middleware Not Executing
      • Middleware Errors
    • Documentation Issues
      • Swagger UI Not Working
    • Logging Issues
      • Logs Not Appearing
    • Troubleshooting Async/Await Issues
      • Coroutine Was Never Awaited Warning
      • Mixing Sync and Async Code
      • Event Loop Already Running Error
      • Blocking the Event Loop
      • Database Operations Blocking the Event Loop
      • HTTP Requests Blocking the Event Loop
      • Middleware Not Handling Async Functions
      • Testing Async Functions
      • Handling Exceptions in Async Code
      • Async Context Managers
      • Async Iterators
      • Timeouts in Async Code
      • Cancelling Async Tasks
    • Conclusion
  • Migration Guide: Upgrading to APIFromAnything 1.0.0
    • Overview of Changes
      • Major Changes
      • Breaking Changes
    • Step-by-Step Migration Guide
      • 1. Update Your Dependencies
      • 2. Update Middleware Implementation
      • 3. Update API Endpoints for Async Support
      • 4. Update Database Operations
      • 5. Update HTTP Client Code
      • 6. Update Security Decorators
      • 7. Update Error Handling
      • 8. Update Testing Code
      • 9. Update Configuration Options
      • 10. Update Performance Optimization Code
    • Common Migration Issues and Solutions
      • Issue 1: Coroutine Was Never Awaited Warning
      • Issue 2: Event Loop Already Running Error
      • Issue 3: Middleware Not Handling Async Functions
      • Issue 4: Testing Async Functions
      • Issue 5: Mixing Sync and Async Code
    • Conclusion
  • Monitoring and Alerting
    • Overview
    • Metrics
      • Request Metrics
      • Database Metrics
      • Cache Metrics
      • System Metrics
    • Monitoring Setup
      • Docker Compose
      • Configuration
        • Prometheus
        • Grafana
        • AlertManager
    • Dashboards
    • Alerts
    • Integration with Application Code
      • Middleware
      • Custom Metrics
    • Accessing Monitoring Tools
    • Customizing Monitoring
      • Adding Custom Metrics
      • Adding Custom Dashboards
      • Customizing Alerts
    • Best Practices
  • Environment Configuration and Monitoring
    • Environment Configuration
      • Configuration Structure
      • Configuration Files
      • Usage
      • Environment Types
      • Configuration Categories
    • Logging
      • Logging Features
      • Logging Configuration
      • Usage
    • Monitoring
      • Monitoring Components
      • Metrics
      • Dashboards
      • Alerts
      • Integration
    • Docker Compose Setup
    • Getting Started
    • Best Practices
  • Production Readiness
    • Cleanup and Optimization
    • Docker Support
    • Health Checks
    • Documentation
    • Security
    • Next Steps
  • GitHub and ReadTheDocs Deployment
    • Overview
    • GitHub Actions Setup
      • Prerequisites
      • Required Secrets
      • Workflow Files
        • 1. Python Package Workflow (python-package.yml)
        • 2. Documentation Workflow (docs.yml)
        • 3. ReadTheDocs Workflow (readthedocs.yml)
    • ReadTheDocs Setup
      • Prerequisites
      • Configuration File
      • Documentation Requirements
      • MkDocs Configuration
    • Setting Up ReadTheDocs Webhooks
    • GitHub Pages Setup
    • Versioning Documentation
    • Releasing a New Version
    • Troubleshooting
      • GitHub Actions Issues
      • ReadTheDocs Issues
    • Best Practices
      • Documentation
      • Continuous Integration
      • Versioning
    • Conclusion
  • Examples for APIFromAnything
    • Basic Examples
      • Simple API
      • Type Validation
      • Asynchronous API
    • Middleware Examples
      • Logging Middleware
      • Multiple Middleware
    • Security Examples
      • JWT Authentication
      • API Key Authentication
      • Multiple Authentication Methods
    • Performance Examples
      • Caching
      • Request Coalescing
      • Batch Processing
      • Web Decorator
    • Monitoring Examples
      • Metrics Collection
    • Serverless Examples
      • AWS Lambda
      • Vercel
    • Advanced Examples
      • Error Handling
      • Database Integration
      • File Upload
      • WebSocket Support
    • πŸ”Œ Plugin System Examples
      • Basic Plugin Example
      • Advanced Plugin Example
      • Plugin with Dependencies
      • Using Hooks
      • Event Handling Plugin
  • Contributing to APIFromAnything
    • Code of Conduct
    • Getting Started
      • Prerequisites
      • Setting Up the Development Environment
    • Development Workflow
      • Creating a Branch
      • Making Changes
      • Committing Changes
      • Creating a Pull Request
    • Pull Request Guidelines
    • Code Style
      • Imports
      • Docstrings
      • Type Hints
    • Testing
      • Running Tests
      • Writing Tests
    • Documentation
      • Building Documentation
      • Writing Documentation
    • Reporting Bugs
    • Requesting Features
    • Release Process
    • Community
    • License
  • Contributing to Documentation
    • Documentation Structure
    • Setting Up the Documentation Environment
    • Writing Documentation
      • File Format
      • Adding a New Page
      • Code Examples
      • Cross-References
    • Documentation Deployment
    • Documentation Style Guide
    • Getting Help
  • Documentation dependencies
APIFromAnything
  • Search


© Copyright 2025, APIFromAnything Team.

Built with Sphinx using a theme provided by Read the Docs.