Official Python SDK for xR2 product API
Project description
xR2 SDK (Python)
Official Python client for xR2 APIs.
Installation
pip install xr2-sdk
Quickstart (Sync)
from xr2_sdk.client import xR2Client
client = xR2Client(api_key="YOUR_PRODUCT_API_KEY")
prompt = client.get_prompt(slug="welcome")
# Send an event
event = client.track_event(
trace_id=prompt.trace_id,
event_name="signup_success",
category="user_lifecycle",
fields={"user_id": "123", "source": "web"},
)
Quickstart (Async)
import asyncio
from xr2_sdk.client import AsyncxR2Client
async def main():
client = AsyncxR2Client(api_key="YOUR_KEY")
try:
prompt = await client.get_prompt(slug="welcome")
event = await client.track_event(
trace_id=prompt.trace_id,
event_name="cta_clicked",
category="engagement",
fields={"user_id": "u-1"},
)
finally:
await client.aclose()
asyncio.run(main())
Endpoints
- POST
/api/v1/get-prompt→ returns prompt content andtrace_id - POST
/api/v1/events→ records an event associated withtrace_id
Configuration
api_key: Product API key (sent asAuthorization: Bearer <key>)timeout: Request timeout (seconds)total_retries,backoff_factor: Retry policy (sync) / lightweight retry (async)
Optional Parameters
For get_prompt():
version_number: Specific version number to fetchstatus: Version status filter -draft,testing,production,inactive,deprecated
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
xr2_sdk-0.1.0.tar.gz
(4.7 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
File details
Details for the file xr2_sdk-0.1.0.tar.gz.
File metadata
- Download URL: xr2_sdk-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6950a434234d6191c21357d1258c81a015dd8e7e073bad927b9dcef08296ced3
|
|
| MD5 |
347eb65084d83f9fd54258fe57901f40
|
|
| BLAKE2b-256 |
fe3fb2df28cefd9efa5efb5366170b4a6e5afc06872ea6ee027a0c43c75337a9
|
File details
Details for the file xr2_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xr2_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d4a57407abafe9cd5aa6aa6cf63c24d4992d64b8715c6e846d5233e26f38684
|
|
| MD5 |
39cdd5a30e7d7845844c28a0e2044cf4
|
|
| BLAKE2b-256 |
72f4ddeb287ed00ef242350983905ef2f99eb006380a0bf1a17c6052874d95d4
|