Python library
The thrustlab package lets you use ThrustLab from your own Python scripts. You can search the
parts catalogue, run simulations and read the results.
It takes care of the fiddly parts of talking to the API. It tries a request again when the network drops, works through long lists page by page, and can wait for a simulation to finish.
Install it
pip install thrustlabYou need Python 3.10 or newer.
Make your first call
You need an API key. Create one on the API keys tab of your Account page, then put it in
the THRUSTLAB_API_KEY environment variable. The library reads it from there.
from thrustlab import Client
client = Client()
motors = client.components.list(type="motor", limit=5)
for motor in motors.data:
print(motor["name"])This prints the names of five motors from the catalogue. To go through the whole catalogue, loop
over motors itself instead of motors.data. The library fetches the next page each time it needs
one.
What you can do with it
| To do this | Use |
|---|---|
| Find motors, propellers and batteries | client.components |
| Run a test bench simulation at one throttle | client.simulations |
| Run it over a range of throttles or other inputs | client.sweeps |
| Fly a drone through a schedule over time | client.flights |
| Keep runs together in projects | client.projects |
| Send in a part that's missing from the catalogue | client.submissions |
| See how many compute units you have left | client.compute_units |
| Get a message when a run finishes | client.webhook_endpoints |
Each of these has its own page in this tab.
When something goes wrong
A failed request raises an exception. It has a code that says what went wrong and a request_id.
Error handling lists the codes.
If you need help, email [email protected] with the
request_id. The source code is in the
thrustlab-sdk repository, and you can report problems
there too.