{"id":27381085,"url":"https://github.com/freerouting/freerouting-python-client","last_synced_at":"2025-04-13T14:46:27.898Z","repository":{"id":287408343,"uuid":"964626533","full_name":"freerouting/freerouting-python-client","owner":"freerouting","description":"Official Freerouting Client Library for Python","archived":false,"fork":false,"pushed_at":"2025-04-11T14:36:31.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T15:47:38.465Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/freerouting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-11T14:14:36.000Z","updated_at":"2025-04-11T14:36:34.000Z","dependencies_parsed_at":"2025-04-11T15:48:47.617Z","dependency_job_id":"6d9942bf-4619-46b9-9c42-942d441b10f1","html_url":"https://github.com/freerouting/freerouting-python-client","commit_stats":null,"previous_names":["freerouting/freerouting-python-client"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freerouting%2Ffreerouting-python-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freerouting%2Ffreerouting-python-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freerouting%2Ffreerouting-python-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freerouting%2Ffreerouting-python-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freerouting","download_url":"https://codeload.github.com/freerouting/freerouting-python-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732388,"owners_count":21152848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-13T14:46:27.162Z","updated_at":"2025-04-13T14:46:27.891Z","avatar_url":"https://github.com/freerouting.png","language":"Python","funding_links":["https://github.com/sponsors/andrasfuchs"],"categories":[],"sub_categories":[],"readme":"# Freerouting Python Client\n\n[![PyPI version](https://badge.fury.io/py/freerouting-client.svg)](https://badge.fury.io/py/freerouting-client)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/MIT)\n[![Python Versions](https://img.shields.io/pypi/pyversions/freerouting-client.svg)](https://pypi.org/project/freerouting-client/)\n\nThis library provides a convenient Python interface for interacting with the [Freerouting API](https://api.freerouting.app/v1) (`api.freerouting.app`). It allows you to manage routing sessions, enqueue jobs, upload designs, download results, and monitor progress programmatically.\n\n**Note:** This client is currently in **Alpha**. The API and client library interface may change in future versions.\n\n## Links\n\n* **Main Freerouting Project:** [github.com/freerouting/freerouting](https://github.com/freerouting/freerouting)\n* **Freerouting Website \u0026 API Access:** [www.freerouting.app](https://www.freerouting.app/)\n* **Freerouting API Documentation:** [Freerouting API v1 Docs](https://github.com/freerouting/freerouting/blob/master/docs/API_v1.md)\n* **PyPI Package:** [pypi.org/project/freerouting-client/](https://pypi.org/project/freerouting-client/)\n* **Issue Tracker:** [github.com/freerouting/freerouting-python-client/issues](https://github.com/freerouting/freerouting-python-client/issues)\n\n## Installation\n\nYou can install the library directly from PyPI:\n\n```bash\npip install freerouting-client\n```\n\n## Getting Started\n\nYou'll need an API key from the [Freerouting website](https://www.freerouting.app/) to use the client.\n\n```python\nfrom freerouting import FreeroutingClient\nimport os\n\n# --- Configuration ---\n# It's recommended to use environment variables for sensitive data like API keys\napi_key = os.environ.get(\"FREEROUTING_API_KEY\")\nif not api_key:\n    raise ValueError(\"Please set the FREEROUTING_API_KEY environment variable.\")\n\n# Optional: If using a local Freerouting instance or a different API version\n# base_url = \"http://localhost:8080\"\n# version = \"dev\"\n# client = FreeroutingClient(api_key=api_key, base_url=base_url, version=version)\n\n# Default usage (connecting to api.freerouting.app/v1)\nclient = FreeroutingClient(api_key=api_key)\n\n# --- Basic Usage ---\ntry:\n    # Check API status\n    status = client.get_system_status()\n    print(f\"API Status: {status.get('status', 'Unknown')}\")\n\n    # Create a session (optional, run_routing_job does this if needed)\n    # session = client.create_session()\n    # print(f\"Created session ID: {session.get('id')}\")\n\nexcept Exception as e: # Consider catching specific FreeroutingError exceptions\n    print(f\"An error occurred: {e}\")\n\n\n# --- Example: Running a Full Routing Job ---\n# Ensure you have a DSN file (e.g., 'my_board.dsn') available\n\ndsn_file = \"path/to/your/my_board.dsn\" # CHANGE THIS PATH\njob_name = \"My Python Client Test Job\"\n\nif not os.path.exists(dsn_file):\n    print(f\"Error: Input file not found at {dsn_file}\")\nelse:\n    print(f\"\\nStarting routing job '{job_name}' for file '{dsn_file}'...\")\n    try:\n        # run_routing_job handles session creation, upload, start, polling, and download\n        output_data = client.run_routing_job(\n            name=job_name,\n            dsn_file_path=dsn_file,\n            # settings={\"router_passes\": 5}, # Optional: Provide router settings\n            poll_interval=10 # Check status every 10 seconds\n            # timeout=600 # Max wait time in seconds (default 3600)\n        )\n\n        print(\"Job completed successfully!\")\n\n        # The output_data contains the result, including the base64 encoded SES file\n        output_filename = output_data.get(\"filename\", \"routed_output.ses\")\n        output_filepath = f\"./{output_filename}\" # Save in current directory\n\n        # Decode and save the output .ses file\n        if \"data\" in output_data:\n            import base64\n            with open(output_filepath, \"wb\") as f:\n                f.write(base64.b64decode(output_data[\"data\"]))\n            print(f\"Output saved to: {output_filepath}\")\n        else:\n            print(\"Warning: Output data field missing in response.\")\n        # print(\"Full output response:\", output_data)\n\n    except Exception as e: # Replace with specific exceptions if defined\n        print(f\"Routing job failed: {e}\")\n\n```\n\n## Contributing\n\nContributions to the Freerouting Python Client are welcome\\! Please refer to the main [Freerouting Contribution Guide](https://www.google.com/search?q=https://github.com/freerouting/freerouting/blob/master/docs/CONTRIBUTING.md) for general guidelines and open an issue or pull request in *this* repository (`freerouting-python-client`).\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.\n\n## 🙏 Support the Main Freerouting Project\n\nDeveloping and maintaining Freerouting requires significant effort. If you find the tool useful, please consider supporting its development\\!\n\n**[Sponsor @andrasfuchs on GitHub Sponsors](https://github.com/sponsors/andrasfuchs)**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreerouting%2Ffreerouting-python-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreerouting%2Ffreerouting-python-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreerouting%2Ffreerouting-python-client/lists"}