Light Logo
Python SDK (v0.22.1)Reference

wriftai

Package initializer for the WriftAI Python client

wriftai package

Submodules

Module contents

Package initializer for WriftAI Python Client.

class Client(api_base_url=None, access_token=None, client_options=None)

Bases: object

Initializes a new instance of the Client class.

  • Parameters:
    • api_base_url (str | None) – The base URL for the API. If not provided, it falls back to the environment variable WRIFTAI_API_BASE_URL or the default api base url.
    • access_token (str | None) – Bearer token for authorization. If not provided it falls back to the environment variable WRIFTAI_ACCESS_TOKEN.
    • client_options (ClientOptions | None) – Additional options such as custom headers and timeout. Timeout defaults to 10s on all operations if not specified.

class ClientOptions

Bases: TypedDict

Typed dictionary for specifying additional client options.

headers : dict[str, Any]

Optional HTTP headers to include in requests.

timeout : Timeout

Timeout configuration for requests.This should be an instance of httpx.Timeout.

transport : BaseTransport | None

Optional custom transport for managing HTTP behavior.

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