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 thatWEFT_API_KEYcontains a current buyerwk_*key.403: inspectcodeanddetailsfor 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.retryableisFalse— resending the conflicting request will conflict again.429: honorRetry-Afterand 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.retryableisTrue; 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
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 weft_sdk-0.21.0.tar.gz.
File metadata
- Download URL: weft_sdk-0.21.0.tar.gz
- Upload date:
- Size: 99.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18085132101068a3bd125ee8b883eec86d64b5aa6fd1d82ccfd1a3bb752abbd9
|
|
| MD5 |
d30c6dcd95c143dc9c408d0e06becf9f
|
|
| BLAKE2b-256 |
b02da1ecba49794620c46f7eca4c69c230045c779f65637749fb0839f394f1d2
|
Provenance
The following attestation bundles were made for weft_sdk-0.21.0.tar.gz:
Publisher:
python.yml on weft-labs/weft-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weft_sdk-0.21.0.tar.gz -
Subject digest:
18085132101068a3bd125ee8b883eec86d64b5aa6fd1d82ccfd1a3bb752abbd9 - Sigstore transparency entry: 2617607970
- Sigstore integration time:
-
Permalink:
weft-labs/weft-sdk@fcee64219e02655e77af0f8fa43eebc4842a331f -
Branch / Tag:
refs/tags/v0.21.0 - Owner: https://github.com/weft-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@fcee64219e02655e77af0f8fa43eebc4842a331f -
Trigger Event:
push
-
Statement type:
File details
Details for the file weft_sdk-0.21.0-py3-none-any.whl.
File metadata
- Download URL: weft_sdk-0.21.0-py3-none-any.whl
- Upload date:
- Size: 343.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4bed1fdeb6ef06419b06f8301d544fbe8e8ac16ebb2ab320b4c804033d87096
|
|
| MD5 |
121333f5c14b074f1f5580ddb96105bf
|
|
| BLAKE2b-256 |
b600e2e92467424e41d2f552c43c21a7f8f208b8a879bd68d5d25e396d4cde8a
|
Provenance
The following attestation bundles were made for weft_sdk-0.21.0-py3-none-any.whl:
Publisher:
python.yml on weft-labs/weft-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
weft_sdk-0.21.0-py3-none-any.whl -
Subject digest:
c4bed1fdeb6ef06419b06f8301d544fbe8e8ac16ebb2ab320b4c804033d87096 - Sigstore transparency entry: 2617607975
- Sigstore integration time:
-
Permalink:
weft-labs/weft-sdk@fcee64219e02655e77af0f8fa43eebc4842a331f -
Branch / Tag:
refs/tags/v0.21.0 - Owner: https://github.com/weft-labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@fcee64219e02655e77af0f8fa43eebc4842a331f -
Trigger Event:
push
-
Statement type: