Skip to content

Commit e3426cd

Browse files
authored
python: update README (#415)
1 parent 59a7c2b commit e3426cd

1 file changed

Lines changed: 39 additions & 30 deletions

File tree

python/README.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,36 @@ The AICA API client module provides simple functions for interacting with the AI
88

99
Refer to https://docs.aica.tech for more information about the AICA System.
1010

11+
## Authentication with an API key
12+
13+
For connecting to AICA Core v4.3.0 and later, an API key is required for authentication.
14+
15+
API keys can be generated in AICA Studio with configurable access scopes. Note that available scopes are limited to
16+
those of the currently logged-in user. A generated API key is only shown once and should be kept secret. For example, it
17+
may be exported as an environment variable. The following example key is shown for demonstrative purposes only:
18+
19+
```shell
20+
export AICA_API_KEY=64ce9e8f-aa46-4ba7-814f-f169c01c957e.RwoH6A1Ti5poNKSizoWrcBEYzh7AkB0kpMq1TR59t6os
21+
```
22+
23+
The API key must then be provided to the constructor with the `api_key` keyword argument:
24+
25+
```python
26+
import os
27+
from aica_api.client import AICA
28+
29+
AICA_API_KEY = os.getenv('AICA_API_KEY')
30+
aica = AICA(api_key=AICA_API_KEY)
31+
```
32+
1133
## Basic usage
1234

1335
```python
36+
import os
1437
from aica_api.client import AICA
1538

16-
aica = AICA()
39+
AICA_API_KEY = os.getenv('AICA_API_KEY')
40+
aica = AICA(api_key=AICA_API_KEY)
1741

1842
if aica.check():
1943
print(f"Connected to AICA Core version {aica.core_version()}")
@@ -57,43 +81,24 @@ conflict with reserved ports. Use the "Open in browser" button from Launcher to
5781
the port from the url.
5882

5983
```python
84+
import os
6085
from aica_api.client import AICA
6186

87+
AICA_API_KEY = os.getenv('AICA_API_KEY')
88+
6289
# connect to a non-default port on the local network
63-
aica = AICA(port=55000)
90+
aica = AICA(api_key=AICA_API_KEY, url='http://localhost:55005/api')
6491

6592
# or connect to a different host address entirely
66-
aica = AICA(url='192.168.0.1', port=55005)
93+
aica = AICA(api_key=AICA_API_KEY, url='http://192.168.0.1:55005/api')
6794
```
6895

69-
## Authentication with an API key
70-
71-
For connecting to AICA Core v4.3.0 and later, an API key is required for authentication.
72-
73-
API keys can be generated in AICA Studio with configurable access scopes. Note that available scopes are limited to
74-
those of the currently logged-in user. A generated API key is only shown once and should be kept secret. For example, it
75-
may be exported as an environment variable. The following example key is shown for demonstrative purposes only:
76-
77-
```shell
78-
export AICA_API_KEY=64ce9e8f-aa46-4ba7-814f-f169c01c957e.RwoH6A1Ti5poNKSizoWrcBEYzh7AkB0kpMq1TR59t6os
79-
```
80-
81-
The API key can then be provided to the constructor with the `api_key` keyword argument:
82-
83-
```python
84-
import os
85-
from aica_api.client import AICA
86-
87-
AICA_API_KEY = os.getenv('AICA_API_KEY')
88-
aica = AICA(api_key=AICA_API_KEY)
89-
```
90-
91-
## Compatability table
96+
## Compatibility table
9297

9398
The latest version of this AICA API client will generally support the latest AICA Core version.
9499
Major version changes to the API client or to AICA Core indicate breaking changes and are not always backwards
95100
compatible. To interact with older versions of AICA Core, it may be necessary to install older versions of the client.
96-
Use the following compatability table to determine which client version to use.
101+
Use the following compatibility table to determine which client version to use.
97102

98103
| AICA Core version | API protocol version | Matching Python client version |
99104
|-------------------|----------------------|--------------------------------|
@@ -135,12 +140,14 @@ AICA Core versions `v5` and later change some endpoints paths, methods and paylo
135140

136141
### Checking compatibility
137142

138-
Recent client versions include a `check()` method to assess the client version and API compatability.
143+
Recent client versions include a `check()` method to assess the client version and API compatibility.
139144

140145
```python3
146+
import os
141147
from aica_api.client import AICA
142148

143-
aica = AICA()
149+
AICA_API_KEY = os.getenv('AICA_API_KEY')
150+
aica = AICA(api_key=AICA_API_KEY)
144151

145152
# check compatability between the client version and API version
146153
if aica.check():
@@ -152,9 +159,11 @@ else:
152159
The latest client versions also include the following functions to check the configuration details manually.
153160

154161
```python3
162+
import os
155163
from aica_api.client import AICA
156164

157-
aica = AICA()
165+
AICA_API_KEY = os.getenv('AICA_API_KEY')
166+
aica = AICA(api_key=AICA_API_KEY)
158167

159168
# get the current version of this client
160169
print(aica.client_version())

0 commit comments

Comments
 (0)