Skip to main content

d2b-sdk — D2B Python SDK

Spreadsheets for AI Agents: typed, versioned, governed tables behind an agent-native API.

pip install d2b-sdk

The distribution is d2b-sdk; the import package and the command are both d2b (d2b on PyPI is an unrelated project). With uvx, that means uvx --from d2b-sdk d2b ....

from d2b import D2BClient, ConflictError

client = D2BClient(api_key="d2b_pat_...", base_url="https://d2b.dev")
wb = client.workbooks.create(title="monthly")["id"]

# Large files are safe: the SDK drives the async ingest and waits on the job.
client.sources.upload(wb, "sales.xlsx", wait=True)

for t in client.tables.list(wb):
    print(t["name"], t["row_count"])

# Row edits are optimistically locked — a 409 is ConflictError, and the
# contract is to re-read and re-apply rather than retry.
page = client.tables.rows(wb, "sales")
try:
    client.tables.upsert_rows(
        wb, "sales",
        rows=[{"product": "apple", "qty": 3}],
        expected_version=page["edit_version"],
    )
except ConflictError:
    page = client.tables.rows(wb, "sales")

The client is a thin skin over the REST API — every method maps to one endpoint:

  • an Idempotency-Key on every mutating call (retry-safe);
  • exponential-backoff retry on 429 / 5xx. 409 is never retried;
  • problem+json errors raised with their suggested_fix attached (written for LLMs to read and react to);
  • helpers for the parts that bite: jobs.wait(), tables.iter_rows(), webhooks.verify_delivery() (signature + send-time check).

Docs: docs.d2b.dev · API reference · 日本語

CLI

d2b login                                            # browser login; no raw API keys
d2b workbooks create --title monthly
d2b upload sales.xlsx --workbook WB --wait
d2b query 'SELECT 1' --workbook WB
d2b pull --workbook WB                               # transforms/ sheets/ charts/ + d2b.json
d2b pull --data customers                            # track base tables as data/*.csv too
d2b push --commit "$(git rev-parse --short HEAD)"    # re-run what changed, then name the version after the commit
d2b github-workflow > .github/workflows/d2b.yml      # CI: push on merge to main, scheduled pull → PR

Output is JSON on stdout; errors carry their suggested_fix on stderr; exit codes are 0 / 1 (API errors, refused syncs) / 2 (usage). Nothing prompts interactively.

d2b login targets https://d2b.dev unless --base-url or $D2B_BASE_URL says otherwise. For non-interactive use set D2B_API_KEY and D2B_BASE_URL — never pass secrets as command-line arguments (--api-key is not accepted, and secret-shaped strings are redacted from error messages).

License

MIT (LICENSE). "D2B", its name and logo, are trademarks and are not covered by this license.

Metadata

Release files for d2b-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for d2b-sdk 0.1.0
File Size Uploaded
d2b_sdk-0.1.0.tar.gz 69.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for d2b-sdk 0.1.0
File Interpreter ABI Platform
d2b_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 122.6 kB

Release files / d2b_sdk-0.1.0.tar.gz

Download URL d2b_sdk-0.1.0.tar.gz
Size 69.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4d5a4eaf9375a2b579c8b07e95a9611f82dc0440127634c8a2b16a0c25fe3ad1
BLAKE2b-256 checksum
How to use checksums
f83f75247bc39333b6b52cb89e5be56f5c3018b26b95a16b588f26dd628a8cb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / d2b_sdk-0.1.0-py3-none-any.whl

Download URL d2b_sdk-0.1.0-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d18f5bcc063365d609c17feb9d2ec1e3ed26367d4bb0699ae5532540ddf8f375
BLAKE2b-256 checksum
How to use checksums
e1150c8ea77e6af952639a48a91d000245ef10affa3e004f7635d6caecd98b91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release 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