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
Release history Release notifications | RSS feed
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.0.1.tar.gz
(6.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
rudra-1.0.1-py3-none-any.whl
(6.2 kB
view details)
File details
Details for the file rudra-1.0.1.tar.gz.
File metadata
- Download URL: rudra-1.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b12564a02b0a0d61f3864f7337e4a6f0d3a968a214fedd5ce05467fc3ea10e7
|
|
| MD5 |
13d6029adc9f99ae42ac9fb813f43d20
|
|
| BLAKE2b-256 |
d2744ce0111127ee66e250c215f9d7ad5b95f968850f8e5cc7ea89007ef0ec0a
|
File details
Details for the file rudra-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rudra-1.0.1-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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b18c8401dba8e699d59072125cbf90cf2b90ab2ecb99789d34c6a74a985e960
|
|
| MD5 |
f9fc2e8b3dc628232502ab79507a6c31
|
|
| BLAKE2b-256 |
61aa938d3e1c0dd693213872a31491e0d5ac38a0c9436cdbe5f09e9f10fd044f
|