rftools Python Library
Programmatic access to all 203 RF & electronics calculators — typed functions, batch mode, async support, and a CLI. Free tier requires no API key.
pip install rftools
Python 3.9+. Dependencies: httpx, pydantic, click. View on PyPI
Quick Start (free tier)
Requires an API key. Free tier: 5 calls/month — get one free at rftools.io/pricing.
import rftools
result = rftools.calculate('vswr-return-loss', {'vswr': 2.5})
print(f'Return Loss: {result["returnLoss"]:.2f} dB') # 9.54 dB
print(f'Reflection Coeff: {result["reflectionCoeff"]:.3f}') # 0.333rftools.calculate() returns a dict-like CalculatorResult. Access outputs by key.
Typed Category Stubs
IDE-friendly typed functions with parameter names and defaults that match the rftools.io web UI. All 13 categories available.
from rftools.calculators import rf, antenna, pcb
# Parameter names and defaults match the rftools.io web UI
fspl = rf.free_space_path_loss(frequency=2400.0, distance=100.0)
print(f'FSPL: {fspl["pathLoss"]:.1f} dB') # 80.0 dB
dipole = antenna.dipole_antenna(frequency=433.0)
print(f'Dipole length: {dipole["length"]:.0f} mm')
result = pcb.trace_width_current(current=2.0, tempRise=10.0, thickness=1.0)Batch API
Run up to 50 calculations in a single HTTP request — ideal for parameter sweeps. Requires an API-tier key (10,000 calls/month). Get a key.
import rftools
client = rftools.Client(api_key='rfc_live_xxx')
# or: export RFTOOLS_API_KEY=rfc_live_xxx
distances = [10, 50, 100, 500, 1000]
results = client.batch([
('free-space-path-loss', {'frequency': 2400, 'distance': d})
for d in distances
])
for d, r in zip(distances, results):
if r.ok:
print(f'{d:>6}m → {r.values["pathLoss"]:.1f} dB')Async Support
Use AsyncClient for FastAPI services, async Jupyter kernels, or concurrent sweeps.
import asyncio
import rftools
async def main():
async with rftools.AsyncClient(api_key='rfc_live_xxx') as client:
result = await client.calculate('vswr-return-loss', {'vswr': 2.5})
print(result['returnLoss'])
asyncio.run(main())CLI
The rftools command is installed automatically with the package.
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 version
Error Handling
from rftools.exceptions import AuthError, RateLimitError, ValidationError, NotFoundError
try:
result = client.calculate('vswr-return-loss', {'vswr': 2.5})
except RateLimitError as e:
print(f'Quota exceeded. Retry after {e.retry_after}s')
except AuthError:
print('Invalid API key')
except NotFoundError:
print('Unknown calculator slug')
except ValidationError as e:
print(f'Bad inputs: {e.detail}')| Exception | When |
|---|---|
AuthError | Invalid or missing API key |
RateLimitError | Monthly quota exceeded (has .retry_after attribute) |
ValidationError | Bad inputs (HTTP 422) — has .detail attribute |
NotFoundError | Unknown calculator slug |
APIError | Unexpected HTTP error — has .status_code attribute |
All 13 Categories
Import from rftools.calculators.
| Module | Count |
|---|---|
rf | 26 |
pcb | 13 |
power | 20 |
signal | 13 |
antenna | 8 |
general | 21 |
motor | 18 |
protocol | 11 |
emc | 16 |
thermal | 6 |
sensor | 17 |
unit_conversion | 17 |
audio | 17 |
API Key
Set RFTOOLS_API_KEY to avoid passing it explicitly. The module-level helpers and Client() both read it automatically.
export RFTOOLS_API_KEY=rfc_live_xxx
Get a key at /pricing. API tier: $19/mo, 10,000 calls/month.
Ready to automate?
Install the library, get a free API key, and run your first calculation in under a minute.
Or get a free API key (5 calls/month) — no credit card required.