Skip to main content

weft-sdk for Python

The supported Python buyer client for Weft. Generated OpenAPI APIs remain available under weft_sdk.generated as an advanced escape hatch.

Install and authenticate

Create a buyer wk_* key in Dashboard → API keys, then:

pip install weft-sdk
export WEFT_API_KEY="wk_..."

Search

import os

from weft_sdk import Client

api_key = os.environ["WEFT_API_KEY"]
with Client(api_key=api_key) as weft:
    account = weft.me()
    results = weft.search(query="weather data API", max_results=5)

print(account.data)
print(results.results)

The client defaults to https://weft.network.

Bounded paid fetch

Paid fetches require both a maximum cost and an idempotency key. Reuse the key when retrying the same logical purchase after an uncertain response.

from uuid import uuid4

idempotency_key = str(uuid4())
artifact = weft.fetch(
    url="https://merchant.example/data",
    max_cost_usd="0.05",
    idempotency_key=idempotency_key,
)

Handle API errors

All buyer-client methods raise the same WeftError shape, including the HTTP status, stable error code, request ID, retry hint, and structured details.

from weft_sdk import WeftError

try:
    results = weft.search(query="weather data API")
except WeftError as error:
    print(error.status, error.code, error.request_id, error.retryable)
    print(error.details)
    raise
  • 401: confirm that WEFT_API_KEY contains a current buyer wk_* key.
  • 403: inspect code and details for an insufficient balance or spending policy denial before changing the request.
  • 409 (IDEMPOTENCY_CONFLICT): this buyer already used the supplied idempotency key for a different fetch request. Generate a new key for the new operation; the original operation retries unchanged with its own key. retryable is False — resending the conflicting request will conflict again.
  • 429: honor Retry-After and back off.
  • 5xx: retry transient failures with backoff; reuse the idempotency key for a paid fetch.
  • status == 0 (NETWORK_ERROR): the request failed before any Weft response, so the outcome is uncertain. retryable is True; retry with backoff and reuse the idempotency key for a paid fetch.

See the API reference for the complete contract.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weft_sdk-0.14.1.tar.gz (99.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

weft_sdk-0.14.1-py3-none-any.whl (344.8 kB view details)

Uploaded Python 3

File details

Details for the file weft_sdk-0.14.1.tar.gz.

File metadata

  • Download URL: weft_sdk-0.14.1.tar.gz
  • Upload date:
  • Size: 99.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for weft_sdk-0.14.1.tar.gz
Algorithm Hash digest
SHA256 61d950a505ec1980e0e28e27f7c3ddf0501e365a6d7e8ebffc8db2e9d325d188
MD5 25552af196f78df0e4183eed359e62d5
BLAKE2b-256 a9ccb5b867f6edd88be4487cd35b76fe70eec26da1ede635febedb4c13b28c84

See more details on using hashes here.

Provenance

The following attestation bundles were made for weft_sdk-0.14.1.tar.gz:

Publisher: python.yml on weft-labs/weft-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file weft_sdk-0.14.1-py3-none-any.whl.

File metadata

  • Download URL: weft_sdk-0.14.1-py3-none-any.whl
  • Upload date:
  • Size: 344.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for weft_sdk-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ffd82c3d9bdd41874d93614a04eb7bafe951af532f5eb8f285c3e4efc675f2a
MD5 654c585bbb1e7a7b8120a46b0540def8
BLAKE2b-256 9df686f20cbfbefe1106703bbba98c1d2d320cef7dfafabfbc5f6ae58a3740c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for weft_sdk-0.14.1-py3-none-any.whl:

Publisher: python.yml on weft-labs/weft-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.25.0

2 files

0.24.0

2 files

0.23.2

2 files

0.23.1

2 files

0.23.0

2 files

0.21.0

2 files

0.20.0

2 files

0.18.0

2 files

0.17.0

2 files

0.16.0

2 files

0.15.1

2 files

0.15.0

2 files

This release

0.14.1 This release

2 files

0.10.1

2 files

0.9.1

2 files

0.9.0

2 files

0.7.0

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.3.0

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page