Beta API. See the stability policy.
Quickstart
In about five minutes you'll install the Python library, get an API key and run your first simulation. The library is optional. The API reference lists the plain web requests it makes.
Install the library
pip install thrustlabYou need Python 3.10 or newer.
Get an API key
Sign in, open Account and go to the API keys tab. Click Create key and copy the key. ThrustLab shows it only once. Put it in an environment variable so it stays out of your code:
export THRUSTLAB_API_KEY=key_...The library reads the key from there. You can also pass it in your code with Client(api_key="key_..."). See Authentication for more about keys.
Run a simulation
This script makes a project, finds a motor, a propeller and a battery by name, runs a four-rotor simulation at 70 % throttle, and waits for the answer. Four rotors need the Pro plan. On the Free plan, set the rotor count to 1:
"""Quickstart: install thrustlab, set $THRUSTLAB_API_KEY, run this file.
export THRUSTLAB_API_KEY=key_... # never hard-code the key
python examples/quickstart.py
"""
from itertools import islice
from thrustlab import Client
client = Client() # reads $THRUSTLAB_API_KEY from the environment
project = client.projects.create(name="my first project")
print(f"created project {project['id']}")
print("first 5 motors:")
for component in islice(client.components.list(type="motor"), 5):
brand = component["spec_json"].get("brand", "?")
print(f" {component['id']} — {brand} {component['name']}")
# One-hit lookup: find() returns the single match (or raises
# AmbiguousComponentError on >1, NotFoundError on 0) so you don't have to
# round-trip the list yourself. Or paste explicit IDs from the catalog.
motor = client.components.find(name="BadAss 2826-820Kv")
prop = client.components.find(name="10.5x4.5")
battery = client.components.find(
name="Liperior 5000mAh 4S 35C 14.8V Lipo Battery With XT90 Plug"
)
# Run a test bench simulation and wait for the result.
sim = client.simulations.create(
project_id=project["id"],
battery_component_id=battery["id"],
airspeed_m_s=0.0,
density_kg_m3=1.225,
state_of_charge_pct=100,
rotor_groups=[
{
"label": "main",
# Four rotors need the Pro plan. On the Free plan, use "count": 1.
"count": 4,
"motor_component_id": motor["id"],
"propeller_component_id": prop["id"],
"throttle_pct": 70,
}
],
)
result = client.simulations.wait(sim["id"], timeout=300)
print(f"status: {result['status']}")
if result["status"] == "completed":
# Canonical snake_case keys: per-rotor under "1", roll-ups under "All".
print(f"per-rotor thrust: {result['result']['1']['thrust_n']:.2f} N")
print(f"total thrust: {result['result']['All']['total_thrust_n']:.2f} N")
When it works, you'll see the project it made, the first five motors in the catalog, and then the thrust:
created project proj_...
first 5 motors:
comp_... ...
status: completed
per-rotor thrust: ... N
total thrust: ... NChange the air or add a wire
Every run request (a simulation, a sweep and a flight) takes the air as altitude_m, the height above sea level in meters, or as density_kg_m3. Use only one of the two. ThrustLab works out the density for an altitude, and the run keeps that density.
A wire is a gauge and a length, for example {"awg": 14, "length_cm": 10}. Use battery_esc_wire for the wire between the battery and the speed controllers, and esc_motor_wire on a rotor group for the wire to a motor. ThrustLab works out the resistance. You can still give the resistance in milliohms instead. Use only one form for each wire. A gauge that ThrustLab does not list is refused, and the message names the gauges it knows.
Where to go next
- API reference lists every request and what it takes.
- Test bench outputs explains what is in the result.
- Async resources shows how to wait for long runs.
- Python library covers the library in full.