Skip to main content

Global universal API connector with smart routing, transforms, budgets, and privacy.

Project description

ApiBridge Pro

License: MIT Python 3.11+ FastAPI Tests Code style: ruff Sponsor

Enterprise-grade Universal API Gateway with smart routing, PII protection, observability, and budget control.

One endpoint, any provider โ€” with multi-provider routing, schema unification, budgets, and advanced security.

โœจ Features

Core Features

  • YAML Connectors: Define auth, allowed paths, rate limits, retries, and caching in a simple YAML configuration
  • Multi-Provider Routing: Fastest healthy provider with automatic failover
  • JMESPath Transforms: Unify responses across different API providers
  • Budget Guardrails: Track API costs with Redis or in-memory fallback
  • Schema-Drift Sentinel: Validate responses against Pydantic models
  • Record/Replay Mode: Record responses for development and CI testing

Advanced Features โญ NEW

  • ๐Ÿ”’ PII Firewall: Automatic detection and protection of sensitive data with redact/tokenize/encrypt/hash options
  • ๐Ÿ”‘ OAuth2 Auto-Refresh: Automatic client_credentials token management per provider
  • ๐Ÿ“Š Observability: Prometheus metrics + OpenTelemetry distributed tracing
  • ๐Ÿ“ˆ Admin Dashboard: Beautiful real-time dashboard for monitoring budgets, health, and cache statistics

๐Ÿš€ Quick Start

Run locally

# Set your API keys as environment variables
export OPENWEATHER_KEY=YOUR_KEY
export WEATHERAPI_KEY=YOUR_KEY
export GITHUB_TOKEN=ghp_xxx
export SLACK_BOT_TOKEN=xoxb-xxx

# Optional: Redis for budgets (falls back to memory)
export REDIS_URL=redis://localhost:6379/0

# Optional: Enable OpenTelemetry tracing
export OTEL_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

# Optional: Set PII encryption key (auto-generated if not set)
export PII_ENCRYPTION_KEY=your-secret-key-here

# Install dependencies
pip install -r requirements.txt

# Run the server
uvicorn app.main:app --reload --port 8000

Try it

Health check:

curl http://127.0.0.1:8000/health

Admin Dashboard (NEW!):

http://127.0.0.1:8000/admin

Beautiful real-time dashboard showing:

  • System overview
  • Budget tracking with visual indicators
  • Provider health status
  • Rate limiting status
  • Cache statistics

Prometheus Metrics (NEW!):

curl http://127.0.0.1:8000/metrics

Weather (unified response from multiple providers):

# OpenWeatherMap or WeatherAPI (automatically routes to fastest healthy provider)
curl "http://127.0.0.1:8000/proxy/weather_unified/weather?q=Bogota"
# or
curl "http://127.0.0.1:8000/proxy/weather_unified/current.json?q=Bogota"

GitHub user:

curl http://127.0.0.1:8000/proxy/github/user

Slack:

curl -X POST "http://127.0.0.1:8000/proxy/slack/chat.postMessage" \
  -H "Content-Type: application/json" \
  -d '{"channel": "general", "text": "Hello from ApiBridge!"}'

Docker

docker build -t apibridge-pro .
docker run -p 8000:8000 \
  -e OPENWEATHER_KEY=YOUR_KEY \
  -e WEATHERAPI_KEY=YOUR_KEY \
  -e GITHUB_TOKEN=ghp_xxx \
  apibridge-pro

Record/Replay Mode

Perfect for development and CI/CD testing:

# Record mode - captures API responses
export APIBRIDGE_MODE=record
uvicorn app.main:app --reload --port 8000
# Make requests... responses are recorded in-memory

# Replay mode - serves recorded responses without hitting real APIs
export APIBRIDGE_MODE=replay
uvicorn app.main:app --reload --port 8000

๐Ÿ“ Configuration

Edit connectors.yaml to add or modify API connectors. Each connector supports:

Basic Configuration

  • base_url or providers[] for multi-provider setups
  • allow_paths: Regex patterns for allowed endpoints
  • rate_limit: Token bucket configuration
  • cache_ttl_seconds: Response caching duration
  • transforms.response.jmes: JMESPath expression for response transformation
  • budget: Monthly USD limits with configurable actions
  • response_model: Pydantic model name for schema validation

Authentication Options

  • api_key_header: API key in header
  • api_key_query: API key in query parameter
  • bearer: Static bearer token
  • oauth2_client_credentials: Auto-refreshing OAuth2 tokens (NEW!)

PII Protection (NEW!)

pii_protection:
  enabled: true
  auto_scan: true           # Auto-detect PII patterns
  action: redact            # redact | tokenize | encrypt | hash
  field_rules:              # Or specify per-field rules
    email: encrypt
    ssn: redact
    phone: tokenize
    address: hash

OAuth2 Example

auth:
  type: oauth2_client_credentials
  token_url: https://auth.example.com/oauth/token
  client_id: ${OAUTH_CLIENT_ID}
  client_secret: ${OAUTH_CLIENT_SECRET}
  scope: "read write"

See connectors_advanced.yaml for comprehensive examples.

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Client    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         ApiBridge Gateway               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Rate Limiting & Path Check    โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚             โ–ผ                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Cache Layer (GET requests)    โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚             โ–ผ                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Multi-Provider Routing        โ”‚    โ”‚
โ”‚  โ”‚  (Health + Latency Based)      โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚             โ–ผ                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  JMESPath Transformation       โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚             โ–ผ                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Schema Validation (Optional)  โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚             โ–ผ                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Budget Tracking               โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  External APIs   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Monitoring & Observability

Prometheus Metrics

ApiBridge Pro exposes metrics at /metrics:

  • apibridge_requests_total - Total requests by connector, method, status
  • apibridge_request_duration_seconds - Request latency histogram
  • apibridge_upstream_requests_total - Upstream provider requests
  • apibridge_upstream_duration_seconds - Upstream latency
  • apibridge_cache_hits_total - Cache hit count
  • apibridge_cache_misses_total - Cache miss count
  • apibridge_rate_limit_exceeded_total - Rate limit violations
  • apibridge_budget_spent_usd - Current budget spending
  • apibridge_provider_health - Provider health status (1=healthy, 0=unhealthy)
  • apibridge_schema_drift_total - Schema drift detections

OpenTelemetry Tracing

Enable distributed tracing:

export OTEL_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317

Traces include:

  • Gateway request spans
  • Upstream provider calls
  • Cache operations
  • Transform operations

Admin Dashboard

Access the admin dashboard at /admin for:

  • Real-time system metrics
  • Budget tracking with visual progress bars
  • Provider health monitoring
  • Rate limit status
  • Cache statistics
  • Auto-refresh every 10 seconds

๐Ÿ”’ PII Protection

ApiBridge Pro includes enterprise-grade PII protection:

Auto-Scan Mode

Automatically detects and protects:

  • Email addresses
  • Social Security Numbers (SSN)
  • Credit card numbers
  • Phone numbers
  • IP addresses

Field-Level Protection

pii_protection:
  enabled: true
  field_rules:
    user.email: encrypt      # Reversible encryption
    ssn: redact             # Masked output (e.g., "1**-**-***4")
    phone: tokenize         # Consistent hash token
    address: hash           # One-way hash

Protection Actions

  • Redact: Masks with asterisks (keeps first/last char)
  • Tokenize: Deterministic token (same input โ†’ same token)
  • Encrypt: Reversible encryption (requires PII_ENCRYPTION_KEY)
  • Hash: One-way hash (irreversible)

๐Ÿ”‘ OAuth2 Auto-Refresh

Automatic token management for OAuth2 client_credentials flow:

auth:
  type: oauth2_client_credentials
  token_url: https://auth.example.com/oauth/token
  client_id: ${CLIENT_ID}
  client_secret: ${CLIENT_SECRET}
  scope: "read write"
  extra_params:           # Optional additional parameters
    audience: "https://api.example.com"

Features:

  • Automatic token refresh before expiration
  • Per-provider token caching
  • Thread-safe token management
  • Configurable scopes

๐Ÿ“š API Documentation

When running, visit:

To disable docs in production:

export DISABLE_DOCS=true

๐Ÿ—๏ธ Production Deployment

Docker Compose Example

version: '3.8'
services:
  apibridge:
    build: .
    ports:
      - "8000:8000"
    environment:
      - REDIS_URL=redis://redis:6379/0
      - OTEL_ENABLED=true
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317
      - PII_ENCRYPTION_KEY=${PII_ENCRYPTION_KEY}
    depends_on:
      - redis
      - jaeger

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

  jaeger:
    image: jaegertracing/all-in-one:latest
    ports:
      - "16686:16686"  # UI
      - "4317:4317"    # OTLP gRPC

  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"

Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: apibridge-pro
spec:
  replicas: 3
  selector:
    matchLabels:
      app: apibridge-pro
  template:
    metadata:
      labels:
        app: apibridge-pro
    spec:
      containers:
      - name: apibridge
        image: apibridge-pro:latest
        ports:
        - containerPort: 8000
        env:
        - name: REDIS_URL
          value: "redis://redis-service:6379/0"
        - name: OTEL_ENABLED
          value: "true"
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          value: "http://otel-collector:4317"
        livenessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 5

๐Ÿค Contributing

Contributions welcome! Please feel free to submit a Pull Request.

For more details, see:

๐Ÿ’– Sponsor This Project


ApiBridge Pro is 100% open source and maintained with love by Lukas Londono.

If you find this project useful and want to support ongoing development:

Why sponsor?

  • โœจ Help maintain and improve ApiBridge Pro
  • ๐Ÿš€ Fund new features and integrations
  • ๐Ÿ“š Support documentation and tutorials
  • ๐Ÿ› Faster bug fixes and security updates
  • ๐ŸŒ Keep this project free and open source for everyone

What your sponsorship enables:

  • More connector templates (OpenAI, Stripe, Twilio, and 100+ more)
  • Advanced features (GraphQL support, WebSocket proxying, gRPC)
  • Performance improvements and optimizations
  • Professional support and consulting
  • Community events and workshops

Other ways to support:

  • โญ Star this repository
  • ๐Ÿฆ Share on Twitter/LinkedIn
  • ๐Ÿ“ Write a blog post or tutorial
  • ๐Ÿ—ฃ๏ธ Speak about ApiBridge Pro at meetups
  • ๐Ÿค Contribute code, docs, or connector templates

Every contribution, big or small, makes a difference! ๐Ÿ™

๐Ÿ“„ License

MIT License - see LICENSE for details.

Copyright ยฉ 2025 Lukas Londono

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

apibridge_pro-0.1.0.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

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

apibridge_pro-0.1.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file apibridge_pro-0.1.0.tar.gz.

File metadata

  • Download URL: apibridge_pro-0.1.0.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for apibridge_pro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe5a47732bfc27fbf85da9a8f4e2516429410002ded3bb02bbde3df9099b6e4d
MD5 74ed051bcc5f25a0c80861382e40b172
BLAKE2b-256 8e904b4e6594a347073f0583d41987be1e7b8ced523aeb5106a8dee3ff230efb

See more details on using hashes here.

Provenance

The following attestation bundles were made for apibridge_pro-0.1.0.tar.gz:

Publisher: publish.yml on lukaslondono77/ApiBridgePro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apibridge_pro-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: apibridge_pro-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for apibridge_pro-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31bb742a32c02c483b3efbbcc90b95422638a9940b5056a9dfc9df5085c6b718
MD5 0f68577becf6b0f83f36037118fda4bd
BLAKE2b-256 4f3acb0e2a3562810e904edddcbf7757aa868c1e344f76ed6ca64298f984d881

See more details on using hashes here.

Provenance

The following attestation bundles were made for apibridge_pro-0.1.0-py3-none-any.whl:

Publisher: publish.yml on lukaslondono77/ApiBridgePro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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