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",
    whitelist_routes=["/health", "/metrics"],  # Optional: routes to skip tracking
    tracklist_routes=["/api/v1"]  # Optional: routes to track specifically
)

@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
  • api_key: Your UsageFlow API key
  • whitelist_routes (optional): List of routes to skip tracking
  • tracklist_routes (optional): List of routes to track specifically

Features

  • Automatic request tracking
  • Support for whitelisting and tracklisting routes

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.0.tar.gz (4.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.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: usageflow_flask-0.3.0.tar.gz
  • Upload date:
  • Size: 4.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.0.tar.gz
Algorithm Hash digest
SHA256 065cf5ff3e7e30a6a33c5144864e7bb8e42006a8a73b0dda9adf2b023714a866
MD5 8766807b9a501f47f988cee96af84cef
BLAKE2b-256 4a73aefe01f4c7ef36e0fb82965f6555b6d2f6f587483ef99467c8b0d89ada8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for usageflow_flask-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92f20706f53aa46d9d658a856e24bf521fcba4d30af3245c8082edb46f9ba0e1
MD5 ff56f62653e295cff4bb85dc19dae1be
BLAKE2b-256 0df349963d7ad7f8e3091e798b0986e88bac4d40731481ffd6efde6333b9e808

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