Skip to content
Documentation sections

rftools Python Library

Programmatic access to all 257 RF and electronics calculators and the simulation jobs: typed functions, batch calls, target solves, async support and a CLI. Every call needs a key; a free one covers 5 calls a month.

Install

pip install rftools-io. Python 3.12 or later; it brings httpx, pydantic and click. View on PyPI.

API key

rftools login (or rftools.Client().login()) prints a page and a code: open the page, sign in, approve the code, and the key is saved to your user's credentials file, readable by you only. Or set RFTOOLS_API_KEY, which takes precedence. rftools.Client() and the module-level helpers read either; an explicit api_key= wins over both. Keys start with rfc_; see Authentication.

Quick start

rftools.calculate() returns a CalculatorResult: read outputs by key, or .values, .warnings and .provenance.

Typed category stubs

One module per calculator category, one function per calculator, with parameter names and defaults that match the web pages. A slug becomes a function name with - as _, and a name that would start with a digit takes a calc_ prefix.

SDK modules
ModuleCalculatorsFor example
rftools.calculators.rf36rf.calc_5g_nr_band_lookup(), rf.calc_5g_nr_link_budget()
rftools.calculators.pcb36pcb.aperture_diagonal(), pcb.asymmetric_stripline()
rftools.calculators.power23power.battery_charge_time(), power.battery_internal_resistance()
rftools.calculators.signal14signal.adc_snr(), signal.am_modulation_index()
rftools.calculators.antenna11antenna.antenna_beamwidth(), antenna.antenna_downtilt()
rftools.calculators.general24general.calc_555_timer(), general.bjt_bias_point()
rftools.calculators.motor24motor.battery_runtime_motor(), motor.bldc_efficiency()
rftools.calculators.protocol11protocol.can_bus_timing(), protocol.clock_jitter()
rftools.calculators.emc16emc.cable_shield_effectiveness(), emc.chassis_resonance()
rftools.calculators.thermal6thermal.heatsink_calculator(), thermal.heatsink_selection()
rftools.calculators.sensor17sensor.calc_4_20ma_transmitter(), sensor.accelerometer_sensitivity()
rftools.calculators.unit_conversion19unit_conversion.angle_units(), unit_conversion.awg_wire()
rftools.calculators.audio18audio.amplifier_clipping(), audio.audio_adc_snr()
rftools.calculators.iot2iot.ble_link_budget(), iot.lora_link_budget()

Solve for a Target

client.solve() finds the value of one input that brings an output to a target and returns it with the forward result at exactly that value, computed by POST /api/py/v1/calculate/solve. One metered call. Available from rftools-io 0.4.0.

Python
import rftools

client = rftools.Client()

# The trace width that reaches 50 Ω on 1.51 mm FR-4, rounded to a 0.001 mm grid
result = client.solve(
    "microstrip-impedance",
    {"substrateHeight": 1.51, "dielectricConstant": 4.5, "copperThickness": 35},
    "traceWidth", "impedance", 50,
    grid=0.001,
)
print(result.value, result.reached, result.evaluations)
print(result.result.values["impedance"])

Client.solve(slug, inputs, solve_for, target_output, target_value, grid=None, range=None) returns a SolveResult with .value, .unrounded, .reached, .evaluations, .warnings and .result, the same CalculatorResult client.calculate() returns for the inputs with solve_for set to .value. A target the search cannot reach still returns, with .reached False and the nearest value found, and still costs one call. See Solve for a target for the fields, the search range and the refusals.

Batch

Up to 50 calculations in one request, for sweeps; one call per item computed. The batch endpoint is part of the API plan; see pricing (API $39.90 a month, 10,000 calls).

Python
results = client.batch([
    ("vswr-return-loss", {"vswr": 1.5}),
    ("vswr-return-loss", {"vswr": 2.0}),
    ("free-space-path-loss", {"frequency": 2400, "distance": 0.05}),
])
for r in results:
    print(r.values if r.ok else r.error)

Usage

The monthly allowance belongs to the account; every key of the account draws on it.

Python
usage = client.usage()             # GET /v1/usage, never metered
print(usage.used, "of", usage.allowance, "used; resets", usage.reset_at)
for key in usage.keys:
    print(key.key_id, key.label, key.used)

result = client.calculate("vswr-return-loss", {"vswr": 2.5})
print(result.usage.remaining)      # from this response's X-Usage-* headers

Simulation jobs

Parameters and files are checked locally against the job type's contract before anything is sent. A job that ends in failed raises JobFailed with its errorKind as .kind. See Simulation jobs.

Python
job = client.submit_job("sat_link_budget", {"latitude_deg": 40.7, "longitude_deg": -74.0})
job = job.wait(timeout=600)        # polls as the web app does
print(job.status, job.result())    # a summary; job.result(full=True) for all of it

est = client.estimate_job("fdtd_sparam", {"traceW": 0.42, "subH": 0.51, "solveMode": "express"})
print(est.lane, est.within_budget)  # never charged, no key needed

Async support

AsyncClient for FastAPI services, async notebooks, or concurrent sweeps.

Python
import asyncio
import rftools

async def main():
    async with rftools.AsyncClient() as client:
        result = await client.calculate("vswr-return-loss", {"vswr": 2.5})
        print(result["returnLoss"])

asyncio.run(main())

CLI

The rftools command is installed with the package.

Shell
rftools login                                   # get a key; saved, never printed
rftools calc vswr-return-loss --vswr 2.5
rftools calc vswr-return-loss --vswr 2.5 --json | jq .values
rftools list --category rf
rftools info free-space-path-loss
rftools solve microstrip-impedance --for traceWidth --target impedance=50 --grid 0.001 \
    --param substrateHeight=1.51 --param dielectricConstant=4.5 --param copperThickness=35
rftools sim fdtd_sparam --param solveMode=express --no-wait
rftools estimate fdtd_sparam --param traceW=0.42 --param subH=0.51
rftools version

Error handling

Errors are classified by HTTP status, never by message text. A 500, 502, 503, 504 is retried with backoff before it is raised. See Errors.

SDK exceptions
ExceptionRaised for
ValidationErrorHTTP 400, 422
AuthErrorHTTP 401, 403
QuotaErrorHTTP 402
NotFoundHTTP 404
APIErrorHTTP 409, 500, 503
RateLimitErrorHTTP 429
JobFailedA job that ended in failed; .kind is its errorKind.
LoginErrorrftools login delivered no key; .error is access_denied or expired_token.

Ready to automate?

Install the library, get a free key, and run a first calculation in under a minute. The REST API behind it is documented in the API reference.