Debian Codegraph @

README.md

raw symbols SCIP
1 # API for the ekey bionyx system - Python
2
3 [![Lint & Test](https://github.com/richardpolzer/ekey-bionyx-api/actions/workflows/lint_test.yml/badge.svg?branch=main)](https://github.com/richardpolzer/ekey-bionyx-api/actions/workflows/lint_test.yml)
4 [![codecov](https://codecov.io/github/richardpolzer/ekey-bionyx-api/branch/main/graph/badge.svg?token=MXJCFJZO5I)](https://codecov.io/github/richardpolzer/ekey-bionyx-api)
5 [![PyPI - Version](https://img.shields.io/pypi/v/ekey-bionyxpy)](https://pypi.org/project/ekey-bionyxpy)
6
7
8 ## Overview
9
10 The ekey_bionyxpy library can be used to interact with the API of the ekey bionyx biometric systems. All the current functions of the API are mapped. The library is written to completely take advantage of async code in Python.
11
12 ---
13
14 ## Features
15
16 - **Get all systems attached to the user**
17 - **Get all webhooks added by the integration**
18 - **Add new webhooks**
19 - **Update existing webhooks**
20
21 ## Enabling the API
22
23 The system must be setup in the online mode. In your app please enable the API by following the picture
24 ![Erklärung](https://github.com/user-attachments/assets/58602bed-af94-43a7-8bfa-aaeaa82e6cde)
25
26 After the API is enabled you can use the library by first implementing AbstractAuth with your custom token handling.
27
28 In the example a token manager is used. You can however use any mechanism you like to retieve an access token.
29
30 ```python
31 from ekey_bionyxpy import AbstractAuth
32
33 class Auth(AbstractAuth):
34 def __init__(self, websession: ClientSession, host: str, token_manager):
35 """Initialize the auth."""
36 super().__init__(websession, host)
37 self.token_manager = token_manager
38
39 async def async_get_access_token(self) -> str:
40 """Return a valid access token."""
41 if self.token_manager.is_token_valid():
42 return self.token_manager.access_token
43
44 await self.token_manager.fetch_access_token()
45 await self.token_manager.save_access_token()
46
47 return self.token_manager.access_token
48 ```
49
50 Once the Authentication is dealt with you can use the lib like so:
51
52 ```python
53 async def main() -> None:
54 async with aiohttp.ClientSession() as session:
55 # Aquire token manager here
56 auth = Auth(
57 session,
58 "https://api.bionyx.io/3rd-party/api",
59 token_manager,
60 )
61 api = BionyxAPI(auth)
62 systems = await api.get_systems()
63 webhooks = await systems[0].get_webhooks()
64
65
66 asyncio.run(main())
67 ```