Skip to main content

VWP Python SDK — primitives for vibe-coded backends (rate limiting, auth, notifications, and more).

Project description

vwp-sdk

Python SDK for VWP — primitives for vibe-coded backends.

pip install vwp-sdk

Quickstart

import vwp

client = vwp.Client(api_key="vwp_test_...")  # or set VWP_API_KEY in env

result = client.rate_limit.check(
    key="login:user@example.com",
    limit=5,
    window="15m",
)
if not result.allowed:
    # Block this request — your handler returns 429 to the end user.
    print(f"Try again in {result.retry_after_seconds}s")

Or, async:

import asyncio
import vwp

async def main():
    async with vwp.AsyncClient(api_key="vwp_test_...") as client:
        result = await client.rate_limit.check(
            key="login:user@example.com", limit=5, window="15m",
        )
        print(result)

asyncio.run(main())

What's in this release (0.2.0a1)

  • vwp.rate_limit.check(...)SECURITY-RATE-LIMIT-001, fully wired against https://api.vibewithprimitiveai.com/v1.
  • vwp.auth.magic_link.request(email, return_to, ...) — issues a single-use magic link via email (Azure Communication Services on our side).
  • vwp.auth.magic_link.exchange(request | url | dict, handle?) — turns a clicked link into a signed JWT session. SDK pulls _vwp_h out of the request URL automatically.
  • vwp.Client / vwp.AsyncClient — explicit clients for connection reuse.
  • Typed errorsApiKeyError (401), BadRequestError (400), MetaRateLimitedError (429), ServerError (5xx), NetworkError (no response).

Other modules (vwp.notify, vwp.data, vwp.queue) are present as stubs and will be implemented in subsequent releases. Calling them raises NotImplementedError with a pointer to the docs.

Magic-link quickstart

import vwp

client = vwp.Client(api_key="vwp_test_...")

# Step 1 — user types their email
r = client.auth.magic_link.request(
    email="user@example.com",
    return_to="https://yourapp.com/dashboard",
)
# r.expires_at — when the link expires (default 15 min)
# r.delivery_status — "queued"

# Step 2 — user clicks the link, your callback handler runs:
session = client.auth.magic_link.exchange(request)  # request from your framework
# Or pass the URL/handle directly:
session = client.auth.magic_link.exchange(handle="<_vwp_h value from URL>")

# session.session.user_id, session.session.email — for your user table upsert
# session.jwt — set as a HttpOnly cookie

Errors

Every error subclasses vwp.VWPError. Catch the base class to handle anything:

try:
    result = vwp.rate_limit.check(key="...", limit=5, window="15m")
except vwp.ApiKeyError as e:
    print("Bad API key:", e.request_id)
except vwp.BadRequestError as e:
    print("Bad input:", e.field, e.message)
except vwp.VWPError as e:
    print("Other VWP error:", e)

Compatibility

Python 3.9+. Production-tested on 3.12.

License

Apache-2.0.

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

vwp_sdk-0.5.0a1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

vwp_sdk-0.5.0a1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file vwp_sdk-0.5.0a1.tar.gz.

File metadata

  • Download URL: vwp_sdk-0.5.0a1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for vwp_sdk-0.5.0a1.tar.gz
Algorithm Hash digest
SHA256 44978c06d2e08667613a87720948166b8f2d37293833c8841db9d3972ef2a781
MD5 26a3c35dbb91f4f46f34a45ec0a1579f
BLAKE2b-256 70d9977dc7bda46dcffac69aed065ae8a62f455d893b9aa1e5d109cea37bd15e

See more details on using hashes here.

File details

Details for the file vwp_sdk-0.5.0a1-py3-none-any.whl.

File metadata

  • Download URL: vwp_sdk-0.5.0a1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for vwp_sdk-0.5.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 14f62b9310ae75524fd5486205e9096d3038bfaa7f53a761a62e517b26407165
MD5 32df1ac837a71cf845706e79a2a800b7
BLAKE2b-256 8dd1c5c4f5c7b9670e7d58710ae4fb8765e2340405deb7d45c73da74270c727f

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