Skip to main content

tigzig-api-monitor

Lightweight FastAPI middleware for centralized API monitoring. Automatically captures request/response metrics and sends them to a central monitoring service.

Installation

pip install tigzig-api-monitor

Quick Start

from fastapi import FastAPI
from tigzig_api_monitor import APIMonitorMiddleware

app = FastAPI()

# Add the monitoring middleware
app.add_middleware(
    APIMonitorMiddleware,
    app_name="YOUR_APP_NAME",  # Required: identifies your app in logs
)

Configuration

Set these environment variables:

Variable Required Description
API_MONITOR_URL Yes URL of the monitoring service (e.g., https://logger.tigzig.com/log)
API_MONITOR_KEY Yes API key for authentication

Features

  • Non-blocking: Logs are sent asynchronously, never slowing down your API
  • Automatic capture: Request method, endpoint, status code, response time
  • Privacy-safe: IP addresses are hashed, not stored
  • Lightweight: Minimal dependencies (just httpx and starlette)
  • Fire-and-forget: Logging failures don't affect your API
  • Noise filtering: Automatically skips health checks, bots, and vulnerability scanners

What Gets Logged

Each request automatically captures:

  • App name (configured)
  • Endpoint path (no query params for privacy)
  • HTTP method (GET, POST, etc.)
  • Response status code
  • Response time in milliseconds
  • Client IP (sent to service, hashed before storage)
  • User-Agent header
  • Origin header
  • Referer path (no query params)

Example

import os
from fastapi import FastAPI
from tigzig_api_monitor import APIMonitorMiddleware

# Set environment variables (or use .env file)
os.environ["API_MONITOR_URL"] = "https://logger.tigzig.com/log"
os.environ["API_MONITOR_KEY"] = "your-api-key"

app = FastAPI()

# Add monitoring - that's it!
app.add_middleware(APIMonitorMiddleware, app_name="MY_BACKEND")

@app.get("/")
def read_root():
    return {"message": "Hello World"}

# Every request to this API will now be monitored automatically

Whitelist Mode (v1.3.0+) - RECOMMENDED

The best way to filter noise is to only log YOUR endpoints. Use include_prefixes to specify which paths to log:

# Only log paths starting with these prefixes
app.add_middleware(
    APIMonitorMiddleware,
    app_name="MY_BACKEND",
    include_prefixes=("/excel/", "/stock/", "/api/", "/mcp/"),
)

This is much cleaner than trying to exclude infinite junk paths. You know your endpoints - just whitelist them.

Blacklist Mode (v1.1.0+)

If you prefer blacklist mode, the middleware automatically skips logging for:

  • Health check endpoints (/, /health, /healthz, /ready)
  • Static files (/favicon.ico, /robots.txt, /sitemap.xml)
  • Vulnerability scanner probes (/.env, /wp-admin, /vendor/phpunit/..., etc.)
  • Common bot paths (/_next/, /js/, /css/, etc.)

Customize Blacklist

# Add additional paths to exclude
app.add_middleware(
    APIMonitorMiddleware,
    app_name="MY_BACKEND",
    exclude_paths={"/internal", "/metrics", "/debug"},
    exclude_prefixes=("/admin/", "/private/"),
)

# Log everything (disable all filtering)
app.add_middleware(
    APIMonitorMiddleware,
    app_name="MY_BACKEND",
    include_noise=True,
)

License

MIT

Metadata

Release files for tigzig-api-monitor 1.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tigzig-api-monitor 1.13.0
File Size Uploaded Provenance Actions
tigzig_api_monitor-1.13.0.tar.gz 12.9 kB Without provenance Details for tigzig_api_monitor-1.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tigzig-api-monitor 1.13.0
File Interpreter ABI Platform Actions
tigzig_api_monitor-1.13.0-py3-none-any.whl Python 3 none any Details for tigzig_api_monitor-1.13.0-py3-none-any.whl

Total release size: 27.2 kB

Release files / tigzig_api_monitor-1.13.0.tar.gz

Download URL tigzig_api_monitor-1.13.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9cca5daa8282fb9df397d93aecc0f2f4090d774c649752dcedfe004cac4bf9a8
BLAKE2b-256 checksum
How to use checksums
62a75dbeea84c18726f31e9c5d1cfa6cbf987dd6b0fd09b0162e90a0a62a7594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.6

Release files / tigzig_api_monitor-1.13.0-py3-none-any.whl

Download URL tigzig_api_monitor-1.13.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
239a177f1b3cad01559d080da0da64a7f21ab73f5933b79a03c8dabc5d8eb5df
BLAKE2b-256 checksum
How to use checksums
30320f7d7ecb42f71497dfe36fa06e95a4066556b1ca8dec60335b8cc67c9cf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.6

Security for tigzig-api-monitor 1.13.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page