Freerouting Python Client
This library provides a convenient Python interface for interacting with the Freerouting API (api.freerouting.app). It allows you to manage routing sessions, enqueue jobs, upload designs, download results, stream progress, and monitor jobs programmatically.
Note: This client is currently in Alpha. The API and client library interface may change in future versions.
Links
- Main Freerouting Project: github.com/freerouting/freerouting
- Freerouting Website & API Access: www.freerouting.app
- Freerouting API Documentation: Freerouting API v1 Docs
- PyPI Package: pypi.org/project/freerouting-client/
- Issue Tracker: github.com/freerouting/freerouting-python-client/issues
Installation
You can install the library directly from PyPI (always installs the latest release):
pip install freerouting-client
Pin a version only when you need a reproducible environment (for example pip install "freerouting-client==<version>").
For development:
pip install -e ".[dev]"
Getting Started
You'll need an API key from the Freerouting website to use the hosted cloud API.
from freerouting import FreeroutingClient
import os
api_key = os.environ.get("FREEROUTING_API_KEY")
if not api_key:
raise ValueError("Please set the FREEROUTING_API_KEY environment variable.")
client = FreeroutingClient(api_key=api_key)
status = client.get_system_status()
print(f"API Status: {status.get('status', 'Unknown')}")
Local / self-hosted Freerouting
When running Freerouting locally with authentication disabled, omit the API key and point the client at your local server:
client = FreeroutingClient(
base_url="http://127.0.0.1:37864",
version="v1",
)
Example: Running a Full Routing Job
from freerouting import FreeroutingClient, FreeroutingError
client = FreeroutingClient(api_key=os.environ["FREEROUTING_API_KEY"])
output_data = client.run_routing_job(
name="My Python Client Test Job",
dsn_file_path="path/to/my_board.dsn",
settings={"max_passes": 5},
poll_interval=10,
output_path="routed_output.ses",
)
print(f"Output filename: {output_data.get('filename')}")
API Coverage
| Area | Methods |
|---|---|
| Single-Turn Autorouting | autoroute() |
| System | get_system_status(), get_environment() |
| Sessions | create_session(), list_sessions(), get_session(), get_session_logs(), monitor_session() |
| Jobs | enqueue_job(), list_jobs(), list_all_jobs(), get_job(), get_effective_settings(), update_job_settings(), start_job(), cancel_job() |
| Input / output | upload_input(), upload_input_json(), upload_rules(), download_output(), download_output_json() |
| DRC & diagnostics | get_job_drc(), get_job_drc_summary() |
| Logs & streaming | get_job_logs(), stream_job_logs(), stream_job_output(), stream_job_output_json() |
| Analytics | track_user_action(), identify_user() |
| Workflow | run_routing_job() |
Single-Turn Composite Autorouting (autoroute)
For AI agents, scripts, and headless pipelines, autoroute() runs the entire routing lifecycle in a single HTTP request:
result = client.autoroute(
dsn_file_path="board.dsn",
rules_file_path="board.rules", # optional
router_settings={"autorouter": {"max_passes": 10}},
output_formats=["SES", "DRC_SUMMARY"],
timeout_seconds=120,
)
print(f"Status: {result['status']}")
print(f"Unrouted connections: {result.get('unrouted_connections')}")
print(f"Clearance violations: {result.get('clearance_violations')}")
ses_content = result["outputs"]["SES"]
KiCad JSON workflow
For the KiCad IPC bridge workflow, upload raw JSON and download JSON output:
import json
with open("board.json", encoding="utf-8") as f:
board = json.load(f)
job = client.enqueue_job("KiCad JSON test")
client.upload_input_json(job["id"], board)
client.start_job(job["id"])
# Poll with get_job(job["id"]) or stream progress:
for update in client.stream_job_output_json(job["id"]):
print(update.get("statistics", {}))
result = client.download_output_json(job["id"], output_path="board_routed.json")
DRC Report & Diagnostic Summary
# Full or compact KiCad-compatible DRC report
drc = client.get_job_drc(job_id, compact=True)
print(f"Violations: {len(drc.get('violations', []))}")
# AI-ready root-cause diagnostic summary with congestion zones and hints
summary = client.get_job_drc_summary(job_id)
print(f"Violations count: {summary.get('clearance_violations_count')}")
for hint in summary.get("hints", []):
print(f"Hint: {hint}")
Error Handling
The client raises typed exceptions:
FreeroutingAuthError— invalid or missing credentials (HTTP 401/403)FreeroutingAPIError— other non-success API responsesFreeroutingError— network failures and workflow errors
Contributing
Contributions to the Freerouting Python Client are welcome. Please refer to the main Freerouting Contribution Guide for general guidelines and open an issue or pull request in this repository (freerouting-python-client).
License
This project is licensed under the MIT License — see the LICENSE file for details.
Support the Main Freerouting Project
Developing and maintaining Freerouting requires significant effort. If you find the tool useful, please consider supporting its development.
Metadata
Release files for freerouting-client 2.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| freerouting_client-2.6.0.tar.gz | 17.9 kB | Without provenance | Details for freerouting_client-2.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| freerouting_client-2.6.0-py3-none-any.whl | Python 3 | none | any | Details for freerouting_client-2.6.0-py3-none-any.whl |
Total release size: 30.2 kB
Release files / freerouting_client-2.6.0.tar.gz
| Download URL | freerouting_client-2.6.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d939e6b7d0c4484ea9d2cf67e3b7e569eaf82ddd43500e0a7557a5728a234c87
|
|
BLAKE2b-256 checksum How to use checksums |
20ae7aa26997b41ce3fc66873cf464acd9eb7a6a53d05f20548dc4f049d5b64c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / freerouting_client-2.6.0-py3-none-any.whl
| Download URL | freerouting_client-2.6.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cda5767845957b44a51b5b95e1524d9f1c104d53a8a3f3afb81191325bbd8d6
|
|
BLAKE2b-256 checksum How to use checksums |
96af679030daf2028e0b62d4d9443cecdc7c85f58a29ab9b79430ba80a3a5d1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for freerouting-client 2.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.