Light Logo
Python SDK (v0.28.0)Reference

wriftai

Package initializer for the WriftAI Python client

wriftai package

Submodules

Module contents

Package initializer for WriftAI Python Client.

class Client(access_token=None, api_base_url=None, headers=None, http_client=None, async_http_client=None, max_retries=2)

Bases: object

Initializes a new instance of the Client class.

  • Parameters:
    • access_token (str | None) – Bearer token for authorization. If not provided it falls back to the environment variable WRIFTAI_ACCESS_TOKEN.
    • api_base_url (str | None) – The base URL for the API. It must not contain a trailing slash. If not provided, it falls back to the environment variable WRIFTAI_API_BASE_URL or the default URL.
    • headers (Mapping *[*str , str ] | None) – Optional HTTP headers to include in every request to WriftAI’s API.
    • http_client (Client | None) – Optional custom http client for synchronous requests. If not provided, a default client is created with a 10 second connect timeout.
    • async_http_client (AsyncClient | None) – Optional custom http client for asynchronous requests. If not provided, a default client is created with a 10 second connect timeout.
    • max_retries (int) – Maximum number of retries for failed requests. Applies to rate-limit (429) and server (5xx) errors. Defaults to 2. Set to 0 to disable.

class PaginationOptions

Bases: TypedDict

Options for pagination.

cursor : NotRequired[str]

Cursor for pagination.

page_size : NotRequired[int]

Number of items per page.

exception WebhookNoSignatureError

Bases: WebhookSignatureVerificationError

Initialize WebhookNoSignatureError.

  • Return type: None

exception WebhookNoTimestampError

Bases: WebhookSignatureVerificationError

Initialize WebhookNoTimestampError.

  • Return type: None

exception WebhookSignatureMismatchError

Bases: WebhookSignatureVerificationError

Initialize WebhookSignatureMismatchError.

  • Return type: None

exception WebhookSignatureVerificationError

Bases: ValueError

Error raised when webhook signature verification fails.

exception WebhookTimestampOutsideToleranceError

Bases: WebhookSignatureVerificationError

Initialize WebhookTimestampOutsideToleranceError.

  • Return type: None

verify_webhook(payload, signature, secret, tolerance=300, scheme='v1')

Verify webhook signature.

  • Parameters:
    • payload (bytes) – Raw webhook request body.
    • signature (str) – The signature to verify.
    • secret (str) – The webhook secret.
    • tolerance (int) – Maximum allowed age of the timestamp in seconds. Defaults to 300.
    • scheme (str) – Key for signatures in the signature. Defaults to “v1”.
  • Raises:
  • Return type: None