Skip to main content

waitstate

Python SDK for WaitState - adaptive gating that adds fleet-wide traffic intelligence on top of your existing infrastructure.

Built from a single Rust core via UniFFI. Native performance, no C toolchains required.

Install

pip install waitstate

Quick start

import os
from waitstate import WaitstateClient

client = WaitstateClient(
    publish_key=os.environ["WAITSTATE_PUBLISH_KEY"],
    secret_key=os.environ["WAITSTATE_SECRET_KEY"],
)

# Synchronous, in-memory, zero network calls on the hot path
result = client.gate("free", 1.0)

if not result.allowed:
    return {"error": "rate_limited", "reason": str(result.reason)}, 429

Framework middleware

FastAPI

from fastapi import Depends, FastAPI, Request
from waitstate import WaitstateClient
from waitstate.middleware.fastapi import create_dependency, create_response_hook

client = WaitstateClient(
    publish_key=os.environ["WAITSTATE_PUBLISH_KEY"],
    secret_key=os.environ["WAITSTATE_SECRET_KEY"],
)

app = FastAPI()
gate = create_dependency(client)
app.middleware("http")(create_response_hook(client))

@app.get("/search")
async def search(request: Request, _=Depends(gate)):
    ...

Flask

from flask import Flask
from waitstate import WaitstateClient
from waitstate.middleware.flask import init_app

client = WaitstateClient(
    publish_key=os.environ["WAITSTATE_PUBLISH_KEY"],
    secret_key=os.environ["WAITSTATE_SECRET_KEY"],
)

app = Flask(__name__)
init_app(app, client)

Django

# settings.py
WAITSTATE_PUBLISH_KEY = os.environ["WAITSTATE_PUBLISH_KEY"]
WAITSTATE_SECRET_KEY = os.environ["WAITSTATE_SECRET_KEY"]

MIDDLEWARE = [
    "waitstate.middleware.django.WaitstateMiddleware",
    # ...
]

Agent mode

If you prefer not to embed the SDK, point it at a local waitstate-agent sidecar instead:

client = WaitstateClient(agent_url="http://localhost:9000")

result = client.gate("free", 1.0)

In agent mode, gate calls are HTTP round-trips to the sidecar (~1ms on localhost). The agent handles all background sync and telemetry.

Configuration

Parameter Type Default Description
publish_key str - Required (embedded mode). From the dashboard.
secret_key str - Required (embedded mode). Store in env vars.
agent_url str None Use agent mode instead of embedded.
base_url str https://api.waitstate.io Control plane URL.
site_id str None Shard key for DO routing. Isolates sites within one org.

How it works

  • gate() checks an in-memory policy - synchronous, sub-millisecond in embedded mode.
  • Background tasks send health telemetry (pulses) to the control plane and receive updated policies.
  • If the control plane is unreachable, the SDK fails open (all requests allowed).
  • If the lease expires, the SDK enters safe mode - a fixed RPS cap to prevent runaway traffic.
  • Zero Python dependencies. The compiled Rust core is distributed as a platform-specific wheel.

Supported platforms

Pre-built wheels are available for:

  • Linux x86_64 / aarch64
  • macOS x86_64 / aarch64 (Apple Silicon)
  • Windows x86_64

Documentation

Full docs, API reference, and reflex rule guides: waitstate.io/docs

License

Apache 2.0

Release files for waitstate 0.1.0

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

Built distributions (wheels)

Table of built distributions (wheels) for waitstate 0.1.0
File
waitstate-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
waitstate-0.1.0-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details
waitstate-0.1.0-py3-none-manylinux_2_34_aarch64.whl Python 3 none Linux glibc 2.34+ ARM64 Details
waitstate-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
waitstate-0.1.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size:10.6 MB

Release files / waitstate-0.1.0-py3-none-win_amd64.whl

Download URL waitstate-0.1.0-py3-none-win_amd64.whl
Size 1.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
c03920e9db2cac242e5e775850354ee095115ea4fd2354dc29cf0b78e9e3337f
BLAKE2b-256 checksum
How to use checksums
6b65d9675f9383cf193adea587323fd0a3419636535f7c9a41212550374bf730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / waitstate-0.1.0-py3-none-manylinux_2_34_x86_64.whl

Download URL waitstate-0.1.0-py3-none-manylinux_2_34_x86_64.whl
Size 2.3 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6743345e08684c462376b72e631e792b31c229ecb957d79449669fa1aa93206b
BLAKE2b-256 checksum
How to use checksums
5ad8a96f9560efbf2730bed4fa7eb596cd96dfe81c8d0816013d7bbd2b9bd885
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / waitstate-0.1.0-py3-none-manylinux_2_34_aarch64.whl

Download URL waitstate-0.1.0-py3-none-manylinux_2_34_aarch64.whl
Size 2.3 MB
Tags Linux glibc 2.34+ ARM64 Python 3
SHA-256 checksum
How to use checksums
97cedddb5fef6037ac06177547c2b6612b42aaa437118b7ee8b8716db843e8cf
BLAKE2b-256 checksum
How to use checksums
b7bfd46c6738182d1aa4aec8cec63795b586a88daf9a7f1e11e176cf0cb4f5cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / waitstate-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL waitstate-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 2.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d3897096ec122eefb4bedc0045049e5729f5610b92768ad6054ec4bca96988f9
BLAKE2b-256 checksum
How to use checksums
4c60cdfc67e6ef47b9d6ede454e4968ab7b761c7f9fce6f960cd9c712e830430
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / waitstate-0.1.0-py3-none-macosx_10_12_x86_64.whl

Download URL waitstate-0.1.0-py3-none-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
acc5a227a4daa06916d99e0863bebfb8e1c58dece57a067d362a5a17f611e460
BLAKE2b-256 checksum
How to use checksums
494164db132284d41ac4061cf841a1135a82d29d4f6a3873c34e70d5064f3a47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files

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