{"id":20618222,"url":"https://github.com/tddschn/nssurge-api","last_synced_at":"2025-10-11T11:42:49.732Z","repository":{"id":57679035,"uuid":"491832024","full_name":"tddschn/nssurge-api","owner":"tddschn","description":"NSSurge HTTP API for Python","archived":false,"fork":false,"pushed_at":"2023-07-20T16:28:11.000Z","size":138,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-28T19:29:20.980Z","etag":null,"topics":["aiohttp","api","api-client","api-wrapper","nssurge","python","surge","surge-http-api","surge-module","surge4","surge5"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/nssurge-api/","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/tddschn.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":"2022-05-13T09:12:42.000Z","updated_at":"2025-05-13T09:02:35.000Z","dependencies_parsed_at":"2025-04-15T11:49:08.583Z","dependency_job_id":null,"html_url":"https://github.com/tddschn/nssurge-api","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/tddschn/nssurge-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tddschn%2Fnssurge-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tddschn%2Fnssurge-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tddschn%2Fnssurge-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tddschn%2Fnssurge-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tddschn","download_url":"https://codeload.github.com/tddschn/nssurge-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tddschn%2Fnssurge-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007041,"owners_count":26084228,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aiohttp","api","api-client","api-wrapper","nssurge","python","surge","surge-http-api","surge-module","surge4","surge5"],"created_at":"2024-11-16T12:07:37.381Z","updated_at":"2025-10-11T11:42:49.711Z","avatar_url":"https://github.com/tddschn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NSSurge Python API Client\n\nPython implementation of the [Surge HTTP API spec](https://manual.nssurge.com/others/http-api.html) client using `aiohttp`.\n\nYou can use it to get/set Surge rules / policies / proxy groups, get recent requests / events and much more. \n\nThis projects fully implements the [Surge HTTP API spec](https://manual.nssurge.com/others/http-api.html).\n\nIf you're looking for a command line tool to interact with your running Surge app, check out [NSSurge CLI](https://github.com/tddschn/nssurge-cli).\n\n- [NSSurge Python API Client](#nssurge-python-api-client)\n  - [Installation](#installation)\n    - [pip](#pip)\n  - [Usage](#usage)\n  - [Develop](#develop)\n  - [See also](#see-also)\n\n\n## Installation\n\n### [pip](https://pypi.org/project/nssurge-api/)\n\n```\n$ pip install nssurge-api\n```\n\n## Usage\n\n```python\n# source: https://github.com/tddschn/nssurge-cli/blob/master/nssurge_cli/cap_commands.py\nfrom nssurge_cli.types import OnOffToggleEnum\nfrom nssurge_api import SurgeAPIClient\nfrom nssurge_api.types import Capability\nimport asyncio\n\nasync def get_set_cap(\n    capability: Capability, on_off: OnOffToggleEnum | None = None\n) -\u003e bool | tuple[bool, bool]:\n    \"\"\"\n    Get or set a capability\n    \"\"\"\n    async with SurgeAPIClient(*get_config()) as client:\n        state_orig = await get_cap_state(client, capability)\n        match on_off:\n            case OnOffToggleEnum.on | OnOffToggleEnum.off:\n                await client.set_cap(capability, s2b(on_off))\n            case OnOffToggleEnum.toggle:\n                await client.set_cap(capability, not state_orig)\n            case _:\n                return state_orig\n        state_new = await get_cap_state(client, capability)\n        return state_orig, state_new\n```\n\n## Develop\n\n```\n$ git clone https://github.com/tddschn/nssurge-api.git\n$ cd nssurge-api\n$ poetry install\n```\n\n## See also\n\n- [NSSurge CLI](https://github.com/tddschn/nssurge-cli): Command line Surge HTTP API Client built with this library\n- [Surge HTTP API spec](https://manual.nssurge.com/others/http-api.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftddschn%2Fnssurge-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftddschn%2Fnssurge-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftddschn%2Fnssurge-api/lists"}