Beta API. See the stability policy.
Creating your own components
If a motor, propeller or battery isn't in the catalog, you can add it yourself and use it in your runs. It is private to your account. This article lists the fields each kind of part needs. To add a part on the website, see Add your own part.
You create a part with POST /v1/components. Send a type (motor, battery or propeller), a name and a spec_json with the part's numbers. The reply has an id that starts with comp_. Use that id in a run, the same as a catalog part.
motor = client.components.create(
type="motor",
name="My Custom 4260 800Kv",
spec_json={ ... },
)If a required field is missing, you get a 400 that names the field, says what it means and gives its unit. Keys that ThrustLab doesn't know are stored and ignored.
A successful reply can also have a warnings list. A warning means a number looks unlikely, for example a motor resistance far from what that motor's size and Kv would give. Your part is saved anyway. A warning usually means a mix-up between milliohms and ohms, so check the datasheet again.
Motor
| Field | What it is | Unit | Needed |
|---|---|---|---|
kv | How fast the motor turns for each volt | rev/min per V | Yes |
n | The number of magnet poles | whole number | Yes |
R | Winding resistance measured between two motor wires | ohm | Yes |
diameter | Diameter of the stator or can | mm | Yes |
length | Length of the motor body | mm | Yes |
weight | Weight of the motor | g | Yes |
u_nominal | The voltage at which the no-load current was measured | V | Yes |
iq_nominal | The no-load current, also called idle current | A | Yes |
iq_max | The highest current the motor takes | A | Yes, or power_max |
power_max | The highest power the motor takes | W | Yes, or iq_max |
L | Winding inductance | H | No. Estimated if left out |
inertia | How hard it is to spin the rotor | kg·m² | No. Estimated if left out, but a run over time needs it |
topology | outrunner or inrunner | No. The default is outrunner | |
brand | The maker | No |
Use the resistance from the datasheet, the one measured between two wires. ThrustLab converts it itself. If the no-load current is much too high for a real motor, you get a 400 on spec_json.iq_nominal. That usually means a maximum current went into the wrong field.
Battery
A battery pack needs its size, how its cells are wired, its capacity and weight, and one figure for its internal resistance. A bench power supply (chemistry set to source) needs only series_cells and source_voltage.
| Field | What it is | Unit | Needed |
|---|---|---|---|
chemistry | lipo, lihv, nmc, nca, lfp, nimh or source | Yes | |
length_mm, width_mm, height_mm | The size of the pack | mm, from 1 to 2000 | Yes, for a pack |
series_cells | Cells in series (the S number) | count, at most 24 | Yes |
parallel_cells | Cells in parallel (the P number) | count | Yes, for a pack |
total_capacity_mAh | The capacity of the pack | mAh | Yes, for a pack |
weight_g | The weight of the pack | g | Yes, for a pack |
c_rating | The discharge rating | 1/h | Yes, for a pack, or pack_resistance_mOhm |
pack_resistance_mOhm | The resistance of the whole pack | mΩ | Instead of c_rating |
source_voltage | The voltage of the supply | V | Yes, for a source |
v_min_per_cell | The lowest voltage per cell before the run stops | V | No. Each chemistry has a default |
form_factor | pouch or cylindrical | No. ThrustLab works it out from the chemistry | |
cell_model | The cell, for example 21700 | No. Cylindrical packs only | |
pack_style | flat, hump or t | No. Cylindrical packs only | |
internal_resistance_mOhm | The resistance of one cell | mΩ | No |
brand | The maker | No |
Series cells times parallel cells can't be more than 256.
Propeller
A propeller is described by its blade shape. You give the radius, chord and twist at several points along the blade, from the hub to the tip. The propeller maker on the website builds these lists for you. Saving a propeller needs the Pro plan. A free account gets a 402.
| Field | What it is | Unit | Needed |
|---|---|---|---|
diameter | The diameter of the propeller | inch | Yes |
pitch | The pitch of the propeller | inch | Yes |
weight | The weight of the propeller | g | Yes |
rotation | cw, ccw or both, seen from above | Yes | |
radius | The distance from the axis at each point | m | Yes |
chord | The width of the blade at each point | m | Yes |
twist | The twist of the blade at each point | degrees | Yes |
num_blades | The number of blades, from 1 to 16 | count | No. The default is 2 |
maxRPM | The highest speed the propeller is rated for | rev/min | No |
inertia | How hard it is to spin the propeller | kg·m² | No. Estimated if left out, but a run over time needs it |
brand | The maker | No |
The three lists must have the same length, with at least 2 points and at most 50. radius must increase from the hub to the tip. The tip radius must match the diameter to within 5 percent, because otherwise the numbers describe two different blades. If num_blades isn't a whole number from 1 to 16, you get a 422.
A complete example
This script creates a motor, a battery and a propeller, and prints their IDs:
"""Create your own custom motor, battery, and propeller from spec_json.
Run it:
export THRUSTLAB_API_KEY=key_... # never hard-code the key
python examples/components/create_component.py
A custom component is `POST /v1/components` with three fields: `type`
(motor | battery | propeller), `name`, and a type-specific `spec_json` map. The
create is scoped to your account (source="user", visibility="private"); the
returned resource echoes back an `id` (comp_...) you pass to a simulation.
Each create below is `client.components.create(...)`. Field names, units, and
accepted ranges come from the server-side validators — see the reference page
for the full tables.
Notes on validation:
* Battery: a physical pack needs chemistry, cell layout, capacity, weight_g,
one resistance figure (c_rating or pack_resistance_mOhm), and bounding-box
dims; form_factor is derived from chemistry when omitted.
* Propeller: per-station radius/chord/twist and rotation are required, and
persisting a propeller needs the Pro plan — the create below reports the
tier gate cleanly on a free account.
"""
from thrustlab import Client
from thrustlab.exceptions import APIError
client = Client() # reads $THRUSTLAB_API_KEY from the environment
# ---- motor ---------------------------------------------------------------
# Required: kv, n (pole count), R (phase-to-phase winding resistance, ohms),
# weight, diameter, length, u_nominal, iq_nominal, and one of iq_max /
# power_max. Inductance L and rotor inertia are auto-estimated from
# kv/n/diameter/length/weight — inertia is required for runs over time,
# so give real dimensions and mass.
motor = client.components.create(
type="motor",
name="My Custom 4260 800Kv",
spec_json={
"brand": "Custom",
"kv": 800.0, # rpm per volt
"n": 14, # magnet pole count
"R": 0.042, # phase-to-phase winding resistance (ohm)
"weight": 120.0, # g
"diameter": 42.0, # mm (drives L / inertia estimation)
"length": 25.0, # mm
"u_nominal": 10.0, # Test voltage (V) for no-load current
"iq_nominal": 1.1, # No-load current (A), measured at 10 V
"iq_max": 65.0, # max quadrature current (A)
"power_max": 960.0, # max electrical power (W)
"topology": "outrunner",
},
)
print(f"created motor {motor['id']}")
# ---- battery -------------------------------------------------------------
# chemistry in {lipo, lihv, nmc, nca, lfp, nimh, source}. A physical pack needs
# its cell layout, capacity, weight_g, one resistance figure (c_rating or
# pack_resistance_mOhm), and length/width/height_mm (1..2000 mm). form_factor
# is derived (lipo -> pouch) when omitted. Pack cap: series <= 24, S*P <= 256.
battery = client.components.create(
type="battery",
name="My Custom 4S 5000mAh",
spec_json={
"brand": "Custom",
"chemistry": "lipo",
"series_cells": 4,
"parallel_cells": 1,
"total_capacity_mAh": 5000.0,
"c_rating": 75.0,
"weight_g": 480.0,
"length_mm": 145.0, # required for a physical chemistry
"width_mm": 49.0,
"height_mm": 33.0,
},
)
print(f"created battery {battery['id']}")
# ---- propeller (hobbyist tier or higher) ---------------------------------
# Required: diameter, pitch, rotation, weight, and the per-station blade
# geometry — parallel radius/chord/twist arrays, hub -> tip (<= 50 stations;
# radius and chord in METERS, twist in degrees). inertia is required for
# runs over time and is estimated from weight + diameter when
# omitted.
try:
prop = client.components.create(
type="propeller",
name="My Custom 10.5x4.5",
spec_json={
"brand": "Custom",
"diameter": 10.5, # inch
"pitch": 4.5, # inch
"num_blades": 2,
"rotation": "ccw", # top view; "cw" | "ccw" | "both"
"weight": 14.0, # g
"inertia": 8.3e-5, # kg*m^2, required for runs over time
# per-station geometry, hub -> tip (r/R = 0.20 .. 1.00)
"radius": [0.0267, 0.0400, 0.0600, 0.0800, 0.1000, 0.1200, 0.1334], # m
"chord": [0.016, 0.019, 0.022, 0.021, 0.018, 0.014, 0.008], # m
"twist": [30.0, 24.0, 17.0, 12.8, 10.3, 8.6, 7.8], # deg
},
)
print(f"created propeller {prop['id']}")
except APIError as exc:
# A free account 402s here (propeller persistence is a creator_edit gate).
print(f"propeller create skipped: {exc}")
To use a part in a run, pass its id as motor_component_id or propeller_component_id in a rotor group, or as battery_component_id on the run. For how to read what comes back, see Test bench outputs.