11# ONEKEY API Client
22
33This is the official Python client for the
4- [ ONEKEY] ( https://www.onekey.com/ ) public API.
4+ [ ONEKEY] ( https://www.onekey.com/ ) public API. This package provides both a cli and a python library.
55
6- # Usage
6+ # Installation
7+
8+ The client is available at https://github.com/onekey-sec/python-client or can be installed as a python package:
9+
10+ ``` commandline
11+ pip install onekey-client
12+ ```
13+
14+ # CLI Usage
15+
16+ The client can be used with the onekey command and offers multiple subcommands:
17+
18+ ``` commandline
19+ Usage: onekey [OPTIONS] COMMAND [ARGS]...
20+
21+ Options:
22+ --api-url TEXT ONEKEY platform API endpoint [default:
23+ https://app.eu.onekey.com/api]
24+ --disable-tls-verify Disable verifying server certificate, use only for
25+ testing
26+ --email TEXT Email to authenticate on the ONEKEY platform
27+ --password TEXT Password to authenticate on the ONEKEY platform
28+ --tenant TEXT Tenant name on ONEKEY platform
29+ --token TEXT API token to authenticate on the ONEKEY platform
30+ --help Show this message and exit.
31+
32+ Commands:
33+ ci-result Fetch analysis results for CI
34+ get-tenant-token Get tenant specific Bearer token
35+ list-tenants List available tenants
36+ upload-firmware Uploads a firmware to the ONEKEY platform
37+ ```
38+
39+ To use the ONEKEY platform a valid email & password need to be supplied along with specifying the tenant name to be
40+ used. (SSO authentication is currently not supported.) Preferred alternative is to use a dedicated API token based
41+ authentication, API tokens can be generated on the ONEKEY platform.
42+
43+ The required parameters can be supplied through command line arguments or using environment variables prefixed with
44+ ` ONEKEY_ ` , such as the following two are identical:
45+
46+ ``` commandline
47+ onekey --email "<email>" --tenant "<tenant-name>" --password "<password>" get-tenant-token
48+ ```
49+
50+ ``` commandline
51+ ONEKEY_EMAIL="<email>" ONEKEY_TENANT_NAME="<tenant-name>" ONEKEY_PASSWORD="<password>" onekey get-tenant-token
52+ ```
53+
54+ Environment variables and command line arguments can be also mixed. Using environment variables is useful when the
55+ client is used from CI/CD jobs/tasks.
56+
57+ # API Usage
758
859First, you have to log in and select a tenant:
960
1061``` python
1162from onekey_client import Client
1263
13- YOUR_API_URL = " https://demo .onekey.com/api"
64+ YOUR_API_URL = " https://app.eu .onekey.com/api"
1465
1566client = Client(api_url = YOUR_API_URL )
1667
@@ -19,6 +70,19 @@ tenant = client.get_tenant("Environment name")
1970client.use_tenant(tenant)
2071```
2172
73+ Or use an API Token:
74+
75+ ``` python
76+ from onekey_client import Client
77+
78+ YOUR_API_URL = " https://app.eu.onekey.com/api"
79+
80+ client = Client(api_url = YOUR_API_URL )
81+
82+ client.use_token(API_TOKEN )
83+ ```
84+
85+
2286After you logged in and selected the tenant, you can query the GraphQL API
2387
2488``` python
0 commit comments