Skip to main content

Python SDK for Rudra Auth Platform

Project description

Rudra Python SDK

Official Python SDK for Rudra — managed auth platform powered by Keycloak.

Install

pip install rudra
# or from source
cd sdk/python && pip install -e .

Quick Start

from rudra_sdk import RudraClient

# Connect to Rudra
client = RudraClient(
    "http://localhost:8000",
    email="admin@example.com",
    password="your-password"
)

# Create a project
project = client.projects.create(
    name="My SaaS App",
    realm_name="my-saas-app",
    plan="pro",
    coupon_code="WELCOME50"  # optional
)

# Create users
user = client.users.create("my-saas-app",
    username="janedoe",
    email="jane@example.com",
    password="securepass123",
    first_name="Jane",
    last_name="Doe"
)

# List users with search
users = client.users.list("my-saas-app", search="jane")

# Create an organization
org = client.organizations.create("my-saas-app",
    name="Acme Corp",
    slug="acme-corp",
    allowed_email_domains=["acme.com"]
)

# Add SSO provider
client.sso.add_oidc("my-saas-app",
    alias="google",
    provider_type="google",
    client_id="GOOGLE_CLIENT_ID",
    client_secret="GOOGLE_SECRET"
)

# Create roles and assign
client.roles.create("my-saas-app", name="editor", description="Can edit content")
client.roles.assign("my-saas-app", user_id="user-uuid", role_name="editor")

# Set up webhooks
webhook = client.webhooks.create("my-saas-app",
    url="https://my-app.com/webhooks",
    events=["user.created", "user.deleted", "organization.created"]
)
print(f"Webhook secret: {webhook['secret']}")

# Create coupons
client.coupons.create(
    code="STARTUP30",
    discount_pct=30,
    description="Startup discount",
    max_redemptions=100,
    valid_plans=["pro", "business"]
)

# Analytics
stats = client.analytics.summary("my-saas-app", days=30)
print(f"Total users: {stats['total_users']}")
print(f"Logins (30d): {stats['login_count']}")

API Reference

Resources

Resource Methods
client.auth register(), login(), me()
client.projects create(), list(), get(), update(), delete(), update_auth_settings(), update_branding()
client.users create(), list(), get(), update(), delete(), impersonate()
client.sessions list(), revoke_all(), revoke()
client.organizations create(), list(), add_member(), remove_member(), delete(), invite(), list_invitations()
client.roles create(), list(), assign(), remove(), delete()
client.sso add_oidc(), add_saml(), list(), delete()
client.clients create(), list(), delete()
client.webhooks create(), list(), logs(), delete()
client.coupons create(), list(), validate(), redemptions(), toggle(), delete()
client.analytics summary(), events(), dashboard()

Error Handling

from rudra_sdk import RudraClient, RudraAPIError

try:
    client.users.create("my-realm", username="existing", ...)
except RudraAPIError as e:
    print(f"Error {e.status_code}: {e.detail}")

License

MIT

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

rudra-1.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

rudra-1.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file rudra-1.1.0.tar.gz.

File metadata

  • Download URL: rudra-1.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rudra-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4f8a86e67ee569fce4e4a77e4e910a79f1c2537bb824ceb9eff1bb1040383a60
MD5 cd4092e976adb354656be2863664fef1
BLAKE2b-256 b9906c8be6342a180624dc7a45b887148e2b6e818ebc4725974ac96fcadead54

See more details on using hashes here.

File details

Details for the file rudra-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: rudra-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rudra-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c0a559f2fa06db10bc1f930c56e632e4ba6a2291cefe8446cb0273aca69a3ae
MD5 2d4b324a9ba0e6368ffca0cb1ddc2085
BLAKE2b-256 ada8d7adc673de2518e6805e345712cf61fd27400e70b2470f27c72c9cd6d5f5

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