> ## Documentation Index
> Fetch the complete documentation index at: https://developers.askparable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Install the Python client, authenticate, and call the API.

The Python client is `parable_web_api_sdk`. It covers every operation in
the [API reference](https://developers.askparable.com/api-reference/overview.md). It needs Python 3.12 or later.

## Install

The package is in a private Python package index. Ask your Parable
representative for access. Then install the client and its types:

```bash theme={null}
pip install parable_web_api_sdk parable_types_web_api
```

## Import and authenticate

Create a client with the base URL, your token, and your Workspace. See
[Authentication](https://developers.askparable.com/getting-started/authentication.md) to get a token.

```python theme={null}
import os

from parable_web_api_sdk import ClientConfig, WebApiSDK

base_url = os.environ["PARABLE_API_URL"]
token = os.environ["PARABLE_API_TOKEN"]
workspace = os.environ["PARABLE_WORKSPACE"]  # for example "acme-corp"

sdk = WebApiSDK(
    ClientConfig(
        base_url=base_url,
        auth_token=token,
        default_headers={"X-Tenant": workspace},
    )
)
```

The client sends `Authorization: Bearer ...` and the `X-Tenant` header on
every call.

## Read

Read your membership, then the Provider connections in your Workspace:

```python theme={null}
me = sdk.users.me()
print(me.name, me.email)

connections = sdk.vendors.tenant_connector_instances()
for connection in connections:
    print(connection.name, connection.connection_status)
```

## Update

Stop a Tap. This call needs a Parable token, because an MCP token only
reads. Replace the ID with one from your Workspace. List Taps with
`sdk.tenant_connector_taps.tenant_connector_taps()`.

```python theme={null}
from parable_types_web_api import UpdateTenantConnectorTapInput

tap = sdk.tenant_connector_taps.update_tenant_connector_tap(
    "018f2a3b-9c4d-7e5f-8a6b-1c2d3e4f5a6b",
    UpdateTenantConnectorTapInput(enabled=False),
)
print(tap.id, tap.enabled)
```

The update leaves omitted fields unchanged. `enabled: false` stops the Tap.
`enabled: true` does not add a Tap that the connection's `enabledTaps`
leaves out. To turn on an opt-in Tap, see
[Turn Taps on and off](https://developers.askparable.com/connectors/taps.md#turn-taps-on-and-off).

## Encrypt credentials

Two operations take an encrypted body, such as
`sdk.connectors.add_connector_to_tenant()`. Get your Workspace's public key
and give it to the client once. The client then encrypts the body of each of
these operations:

```python theme={null}
from parable_web_api_sdk import PublicEncryptionKey

key = sdk.security.encryption_key()
sdk.set_public_encryption_key(
    PublicEncryptionKey(public_key=key.public_key, algorithm=key.algorithm, key_id=key.key_id)
)
```

You can also pass `public_encryption_key=` to `ClientConfig`, or
`options=EncryptedRequestOptions(public_encryption_key=...)` to one call.
Encryption needs the `cryptography` package, which the `encryption` extra
installs: `pip install "parable_web_api_sdk[encryption]"`. See
[Encrypted request bodies](https://developers.askparable.com/getting-started/encryption.md).

## Handle errors and retries

The client gives each request 30 seconds. Set `timeout_seconds` in
`ClientConfig`, or pass `timeout_seconds=` to one call, to change it.

The client retries two kinds of failure, each up to 3 times:

* **`429`.** It waits for the seconds in the `Retry-After` header, or 1, 2,
  and 4 seconds when the header is absent, and never more than 300 seconds.
  Set `max_rate_limit_retries` in `ClientConfig` to change the count.
* **A network failure on `GET`, `HEAD`, or `OPTIONS`.** It waits 1, 2, and 4
  seconds. Set `max_network_retries` to change the count. It never retries a
  request that can change something.

Each failure raises one of these exceptions. All of them derive from
`SDKError`.

| Exception | When | Useful attributes |
| - | - | - |
| `APIError` | The API answered with an error status. | `status_code`, `message`, `payload` (the problem body, with `code` and `requestId`) |
| `AuthenticationError` | `401`. A subclass of `APIError`. | As `APIError` |
| `AuthorizationError` | `403`. A subclass of `APIError`. | As `APIError` |
| `RateLimitError` | `429` after the retries. A subclass of `APIError`. | `retry_after`, the seconds to wait, or `None` |
| `ValidationError` | The input failed the client's checks. Nothing was sent. | `errors`, `get_all_messages()` |
| `NetworkError` | No answer arrived. | The message |

```python theme={null}
from parable_web_api_sdk import APIError, NetworkError, RateLimitError

try:
    me = sdk.users.me()
except RateLimitError as err:
    print("try again in", err.retry_after, "seconds")
except APIError as err:
    problem = err.payload if isinstance(err.payload, dict) else {}
    print(err.status_code, problem.get("code"), problem.get("requestId"), err.message)
except NetworkError as err:
    print("no answer:", err)
```

> [!TIP]
>
> Each operation page in the [API reference](https://developers.askparable.com/api-reference/overview.md) shows
> the Python call for that operation, such as `sdk.users.me()`.

For table data, use SQL. See [Parable Data Engine](https://developers.askparable.com/data.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.