Python library for the Bild External API.
This repo is currently intended to be used from source (not published to PyPI yet).
Paste this URL into your agent. It will ask for a Bild JWT, install the
library, call BildClient.verify(), and show you the return value.
https://github.com/AJFrio/Bild-Python/blob/main/AGENT_SETUP.md
After setup, hand it AGENT_USAGE.md (or
https://github.com/AJFrio/Bild-Python/blob/main/AGENT_USAGE.md) so it
resolves the default branch instead of guessing main / master.
Or hand it the files in this repo: AGENT_SETUP.md and AGENT_USAGE.md.
git clone https://github.com/AJFrio/Bild-Python.git
cd Bild-Python
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .Bild APIs require a JWT personal access token. Admin users can issue one in the Bild web app. Tokens issued in the app are listed there with issued-at, issued-by, and expiry.
The client sends that token on every request as:
Authorization: Bearer <your_token>
Copy .env.example to .env and set the token (.env is gitignored):
BILD_API_KEY=YOUR_JWT_TOKENBildClient() loads .env automatically. You can also set the variable in the shell:
export BILD_API_KEY="YOUR_JWT_TOKEN"$env:BILD_API_KEY = "YOUR_JWT_TOKEN"Or pass it directly:
from bild import BildClient
client = BildClient(token="YOUR_JWT_TOKEN")BildClient() with no arguments reads BILD_API_KEY. A missing token raises ValueError. Invalid or expired tokens raise BildAuthError (HTTP 401/403). Other failed responses raise BildAPIError.
from bild import BildClient
client = BildClient() # uses BILD_API_KEY from env
projects = client.api.projects.list()
print(projects)from bild import BildClient
client = BildClient()
users = client.api.users.list()
projects = client.api.projects.list()
print("Users:", users)
print("Projects:", projects)client.api.users.invite(
emails=["person@example.com"],
projects=[{"id": "project-id", "projectAccess": "Editor"}],
pdm_role="Member",
)Bild branches are often not named main or master. Do not guess
those names. Resolve the id, or pass branch_id=None on branch-scoped
methods:
branch_id = client.resolve_branch_id("project-id")
branches = client.api.branches.list("project-id")resolve_branch_id lists the project's branches and prefers a flagged
default (isMain / isDefault / isDefaultBranch), then a main/master
name, then the first branch.
# Official default-branch file list (no branch id needed)
files = client.api.files.list("project-id")
print(files)result = client.api.files.export_universal(
project_id="project-id",
branch_id=None, # resolve_branch_id — not a guessed "main" name
file_id="file-id",
output_format="stl",
)
print(result)links = client.api.shared_links.list("project-id")
print(links)
new_link = client.api.shared_links.create_live(
"project-id",
None, # default branch
name="Review Link",
file_ids=["file-id"],
)
print(new_link)search_result = client.api.search.files("bolt")
print(search_result)A runnable read-only script is in examples/test_search.py:
python examples/test_search.py boltThese map to the groups in the Bild External API reference:
client.api.users— account users (list, invite, update, remove, create_token)client.api.projects— list projectsclient.api.project_users— add / update / remove project accessclient.api.branches— list branchesclient.api.commits— list/get commitsclient.api.files— list files/versions, export STL/STEP, move, deleteclient.api.uploads— initiate / complete file uploadclient.api.checkouts— checkout, cancel, initiate/complete check-inclient.api.shared_links— list, create live/static links, refresh, deleteclient.api.metadata— metadata fields and file metadataclient.api.feedback— feedback items and attachmentsclient.api.packages— account and project packagesclient.api.revisions— list/get/release/cancel revisionsclient.api.approvals— list/get/close approvalsclient.api.boms— list/get/download BOMsclient.api.search— search filesclient.api.webhooks— webhook subscriptions
raw = client.get("projects")
print(raw)python -m pip install -e ".[dev]"
python tools/check.py --allThat runs format check, ruff, mypy, harness linters, and pytest. Agents should start at AGENTS.md; the knowledge base lives in docs/INDEX.md.
If BILD_API_KEY is set (or present in .env), live read-only tests also run against the real API (users, projects, files, search, and the other list/get groups). Write and delete calls are not exercised.