Skip to main content

Flask middleware for UsageFlow - Usage-based pricing made simple

Project description

UsageFlow Flask

⚠️ Beta Notice: This package is currently in beta. While we strive to maintain stability, there may be breaking changes as we continue to improve the API.

The Flask package of UsageFlow provides easy integration with Flask applications for API usage tracking and management.

Installation

pip install usageflow-flask

Quick Start

from flask import Flask, jsonify
from usageflow.flask import UsageFlowMiddleware

app = Flask(__name__)

# Initialize UsageFlow middleware
UsageFlowMiddleware(
    app,
    api_key="your_api_key_here",
    pool_size=10  # Optional: Number of WebSocket connections (default: 10)
)

@app.route("/api/v1/users")
def get_users():
    return jsonify({"users": ["user1", "user2"]})

if __name__ == "__main__":
    app.run()

Configuration

The middleware accepts the following parameters:

  • app: Your Flask application instance (required)
  • api_key: Your UsageFlow API key (required)
  • pool_size (optional): Number of WebSocket connections in the pool (default: 10)

Features

  • Automatic request tracking
  • JWT token extraction and validation
  • Request/response metadata collection
  • Rate limiting and quota management
  • Endpoint blocking support

Development

To contribute to the project:

  1. Clone the repository
  2. Install development dependencies:
    pip install -e ".[dev]"
    
  3. Run tests:
    pytest
    

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usageflow_flask-0.3.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usageflow_flask-0.3.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file usageflow_flask-0.3.3.tar.gz.

File metadata

  • Download URL: usageflow_flask-0.3.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for usageflow_flask-0.3.3.tar.gz
Algorithm Hash digest
SHA256 a66703b72dc17d6ce5ade6355c738b940b9a3a56e41a9bed9060b3b06bec92ad
MD5 7f5eabc94a7585419459c118a1ecba3d
BLAKE2b-256 69e8e1eb014438bd34f23213c2080e7a200a1584db676962d89eed93ae5b29b3

See more details on using hashes here.

File details

Details for the file usageflow_flask-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for usageflow_flask-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f60e4bb23d40c7d066ecad76543c3d6e698b5708c5ff4560a091a2ddc69a72c
MD5 e7a3b15cf130e1acd181f354f0b34e37
BLAKE2b-256 d5dc8f9c95a4bd45f16883a849af544815d4fa1184b4acb3dd18ce9ca83df6cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page