{"id":18543292,"url":"https://github.com/onekey-sec/python-client","last_synced_at":"2025-12-14T13:32:30.543Z","repository":{"id":37928091,"uuid":"347357316","full_name":"onekey-sec/python-client","owner":"onekey-sec","description":"Official Python API client for ONEKEY","archived":false,"fork":false,"pushed_at":"2025-02-10T20:17:03.000Z","size":186,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T10:46:24.136Z","etag":null,"topics":["iot","iot-security","iot-security-testing","security-audit"],"latest_commit_sha":null,"homepage":"https://www.onekey.com","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/onekey-sec.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}},"created_at":"2021-03-13T11:55:03.000Z","updated_at":"2025-02-10T20:17:05.000Z","dependencies_parsed_at":"2023-01-27T17:25:14.814Z","dependency_job_id":"64ff3d73-86ca-43c3-9fd6-696cd319dd0c","html_url":"https://github.com/onekey-sec/python-client","commit_stats":null,"previous_names":["iot-inspector/python-client"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onekey-sec%2Fpython-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onekey-sec%2Fpython-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onekey-sec%2Fpython-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onekey-sec%2Fpython-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onekey-sec","download_url":"https://codeload.github.com/onekey-sec/python-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248087903,"owners_count":21045606,"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":["iot","iot-security","iot-security-testing","security-audit"],"created_at":"2024-11-06T20:13:21.364Z","updated_at":"2025-12-14T13:32:30.481Z","avatar_url":"https://github.com/onekey-sec.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ONEKEY API Client\n\nThis is the official Python client for the\n[ONEKEY](https://www.onekey.com/) public API. This package provides both a cli and a python library.\n\n# Installation\n\nThe client is available at https://github.com/onekey-sec/python-client or can be installed as a python package:\n\n```commandline\npip install onekey-client\n```\n\n# CLI Usage\n\nThe client can be used with the onekey command and offers multiple subcommands:\n\n```commandline\nUsage: onekey [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --api-url TEXT        ONEKEY platform API endpoint  [default:\n                        https://app.eu.onekey.com/api]\n  --disable-tls-verify  Disable verifying server certificate, use only for\n                        testing\n  --email TEXT          Email to authenticate on the ONEKEY platform\n  --password TEXT       Password to authenticate on the ONEKEY platform\n  --tenant TEXT         Tenant name on ONEKEY platform\n  --token TEXT          API token to authenticate on the ONEKEY platform\n  --help                Show this message and exit.\n\nCommands:\n  ci-result         Fetch analysis results for CI\n  get-tenant-token  Get tenant specific Bearer token\n  list-tenants      List available tenants\n  upload-firmware   Uploads a firmware to the ONEKEY platform\n```\n\nTo use the ONEKEY platform a valid email \u0026 password need to be supplied along with specifying the tenant name to be\nused. (SSO authentication is currently not supported.) Preferred alternative is to use a dedicated API token based\nauthentication, API tokens can be generated on the ONEKEY platform.\n\nThe required parameters can be supplied through command line arguments or using environment variables prefixed with\n`ONEKEY_`, such as the following two are identical:\n\n```commandline\nonekey --email \"\u003cemail\u003e\" --tenant \"\u003ctenant-name\u003e\" --password \"\u003cpassword\u003e\" get-tenant-token\n```\n\n```commandline\nONEKEY_EMAIL=\"\u003cemail\u003e\" ONEKEY_TENANT_NAME=\"\u003ctenant-name\u003e\" ONEKEY_PASSWORD=\"\u003cpassword\u003e\" onekey get-tenant-token\n```\n\nEnvironment variables and command line arguments can be also mixed. Using environment variables is useful when the\nclient is used from CI/CD jobs/tasks.\n\n# API Usage\n\nFirst, you have to log in and select a tenant:\n\n```python\nfrom onekey_client import Client\n\nYOUR_API_URL = \"https://app.eu.onekey.com/api\"\n\nclient = Client(api_url=YOUR_API_URL)\n\nclient.login(EMAIL, PASSWORD)\ntenant = client.get_tenant(\"Environment name\")\nclient.use_tenant(tenant)\n```\n\nOr use an API Token:\n\n```python\nfrom onekey_client import Client\n\nYOUR_API_URL = \"https://app.eu.onekey.com/api\"\n\nclient = Client(api_url=YOUR_API_URL)\n\nclient.use_token(API_TOKEN)\n```\n\n\nAfter you logged in and selected the tenant, you can query the GraphQL API\n\n```python\nGET_ALL_FIRMWARES = \"\"\"\nquery {\n  allFirmwares {\n    id\n    name\n  }\n}\n\"\"\"\nres = client.query(GET_ALL_FIRMWARES)\nprint(res)\n\nGET_PRODUCT_GROUPS = \"\"\"\nquery {\n  allProductGroups {\n    id\n    name\n  }\n}\n\"\"\"\nres = client.query(GET_PRODUCT_GROUPS)\ndefault_product_group = next(pg for pg in res[\"allProductGroups\"] if pg[\"name\"] == \"Default\")\n\nGET_ANALYSIS_CONFIGURATIONS = \"\"\"\nquery {\n  allAnalysisConfigurations {\n    id\n    name\n  }\n}\n\"\"\"\nres = client.query(GET_ANALYSIS_CONFIGURATIONS)\ndefault_analysis_configuration = next(conf for conf in res[\"allAnalysisConfigurations\"] if conf[\"name\"] == \"Default\")\n```\n\nYou can upload firmwares:\n\n```python\nmetadata = FirmwareMetadata(\n    name=\"myFirmware\",\n    vendor_name=\"myVendor\",\n    product_name=\"myProduct\",\n    product_group_id=default_product_group[\"id\"],\n    analysis_configuration_id=default_analysis_configuration[\"id\"],\n)\n\nfirmware_path = Path(\"/path/to/firmware.bin\")\nres = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)\nprint(res)\n```\n\n# Support\n\nYou can create a [new issue in this repo](https://github.com/onekey-sec/python-client/issues/new)\nor contact us at support@onekey.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonekey-sec%2Fpython-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonekey-sec%2Fpython-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonekey-sec%2Fpython-client/lists"}