Official Python SDK for the ThrustLab API
Project description
thrustlab — official Python SDK for the ThrustLab API
Install
pip install thrustlab
Requires Python 3.10+.
Quickstart
from thrustlab import Client
client = Client(api_key="key_...") # or set $THRUSTLAB_API_KEY
# Create a project
project = client.projects.create(name="my project")
# Run a simulation and wait for the result
sim = client.simulations.create(
project_id=project["id"],
motor="comp_motor_xxx",
propeller="comp_prop_xxx",
battery="comp_batt_xxx",
throttle=0.7,
)
result = client.simulations.wait(sim["id"], timeout=300)
print(result)
Configuration
| Setting | Constructor arg | Env var | Default |
|---|---|---|---|
| API key | api_key= |
THRUSTLAB_API_KEY |
(required) |
| Base URL | base_url= |
THRUSTLAB_BASE_URL |
https://thrustlab.com |
| Timeout | timeout= |
— | 30 (seconds) |
| Max retries | max_retries= |
— | 3 |
Resources
Every /v1/ route family is exposed as an attribute on the client:
client.api_keys
client.users
client.projects
client.simulations
client.sweeps
client.components
client.submissions
client.starred_components
client.geometry
client.credits
client.subscriptions
client.webhook_endpoints
Error handling
from thrustlab import Client
from thrustlab.exceptions import (
AuthenticationError,
ValidationError,
RateLimitError,
NotFoundError,
)
client = Client()
try:
client.simulations.create(project_id="proj_xxx", motor="comp_xxx", ...)
except ValidationError as exc:
print(f"bad request: {exc.code} ({exc.param}): {exc.message}")
except RateLimitError as exc:
print(f"rate limited; retry after {exc.retry_after}s")
except NotFoundError as exc:
print(f"not found: {exc.message}")
except AuthenticationError as exc:
print(f"auth failed: {exc.message}")
Every error carries .code, .type, .request_id, .http_status, and
.message. ValidationError additionally exposes .param. See
thrustlab.com/docs/guides/errors
for the full code reference.
Pagination
List endpoints return a CursorPager — a lazy iterator that fetches the
next page only when needed:
# Iterate all pages automatically
for project in client.projects.list():
print(project["id"])
# Materialise the first page only
first_page = list(client.projects.list(limit=20))
Async polling
simulations.wait() and sweeps.wait() block until the resource reaches a
terminal state (succeeded, failed, or cancelled) or the timeout fires:
sweep = client.sweeps.create(...)
result = client.sweeps.wait(sweep["id"], timeout=600, poll_interval=2.0)
if result["status"] == "succeeded":
print(result["outputs"])
Webhooks
from thrustlab import Webhook
from thrustlab.exceptions import SignatureVerificationError
WEBHOOK_SECRET = "whsec_..."
@app.post("/webhooks/thrustlab")
async def handle(request):
payload = await request.body()
sig = request.headers["Thrustlab-Signature"]
try:
event = Webhook.verify(payload, sig, WEBHOOK_SECRET)
except SignatureVerificationError:
return Response(status_code=400)
if event.type == "simulation.succeeded":
print(event.data)
Retries
The client automatically retries on 429 (rate limit) and 5xx responses using
exponential backoff with jitter. Set max_retries=0 to disable:
client = Client(max_retries=0)
Links
- Documentation: https://thrustlab.com/docs
- API reference: https://thrustlab.com/docs/reference
- SDK guide: https://thrustlab.com/docs/sdk/python
- Changelog: https://thrustlab.com/docs/changelog
- Issue tracker: https://github.com/kylebedrich/thrustlab/issues
License
MIT
Project details
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 thrustlab-0.1.1.tar.gz.
File metadata
- Download URL: thrustlab-0.1.1.tar.gz
- Upload date:
- Size: 55.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
517d1b134187382fe33ae3c1fbd4bdbc97fa7a54a9be12429283a260ddfd16df
|
|
| MD5 |
b7e6236e67ba6ae66a15cca539c707bb
|
|
| BLAKE2b-256 |
90136bcf846e3f1de0f4e599271e4acdd7c47c6f900dc4f30abfdfe5c07b3687
|
Provenance
The following attestation bundles were made for thrustlab-0.1.1.tar.gz:
Publisher:
sdk-publish.yml on kbedrich/thrustlab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thrustlab-0.1.1.tar.gz -
Subject digest:
517d1b134187382fe33ae3c1fbd4bdbc97fa7a54a9be12429283a260ddfd16df - Sigstore transparency entry: 1398794243
- Sigstore integration time:
-
Permalink:
kbedrich/thrustlab@750aa03279ebc831efd6b50c26ff264ca08797c5 -
Branch / Tag:
refs/tags/sdk-py-v0.1.1 - Owner: https://github.com/kbedrich
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@750aa03279ebc831efd6b50c26ff264ca08797c5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file thrustlab-0.1.1-py3-none-any.whl.
File metadata
- Download URL: thrustlab-0.1.1-py3-none-any.whl
- Upload date:
- Size: 117.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dcea9deb6720eac00f1fe8f5c09e6a03785b1812551d53d30a321f5d6ec90e4
|
|
| MD5 |
89b1f91b83ed5f2d1bd6732e8c6798c0
|
|
| BLAKE2b-256 |
d6760d21286be9bd6b3c789280d739c19ac5f4a90bf9d30881d43ac7fa080511
|
Provenance
The following attestation bundles were made for thrustlab-0.1.1-py3-none-any.whl:
Publisher:
sdk-publish.yml on kbedrich/thrustlab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thrustlab-0.1.1-py3-none-any.whl -
Subject digest:
4dcea9deb6720eac00f1fe8f5c09e6a03785b1812551d53d30a321f5d6ec90e4 - Sigstore transparency entry: 1398794292
- Sigstore integration time:
-
Permalink:
kbedrich/thrustlab@750aa03279ebc831efd6b50c26ff264ca08797c5 -
Branch / Tag:
refs/tags/sdk-py-v0.1.1 - Owner: https://github.com/kbedrich
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@750aa03279ebc831efd6b50c26ff264ca08797c5 -
Trigger Event:
push
-
Statement type: