Client
A module for keeping track of data related to the API.
This module contains the Client and AuthenticatedClient classes. Eth 2 Key Manager API specification dictates that all sensitive endpoints must be authenticated. All endpoints do require authentication so the AuthenticatedClient is the class you interact with. The Client class is never accessed directly.
Refer to the API specification: https://ethereum.github.io/keymanager-APIs/
AuthenticatedClient
Bases: Client
A Client which has been authenticated for use on secured endpoints.
Attributes:
Name | Type | Description |
---|---|---|
token |
str
|
The token to be used for authentication. |
Examples:
>>> from eth_2_key_manager_api_client.client import AuthenticatedClient
>>> authenticated_client = AuthenticatedClient(base_url="http://localhost:7500", token="test_token")
>>> authenticated_client.base_url
'http://localhost:7500'
>>> authenticated_client.token
'test_token'
>>> authenticated_client.get_headers()['Authorization']
'Bearer test_token'
Source code in eth_2_key_manager_api_client/client.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
get_headers()
Get headers to be used in authenticated endpoints
Source code in eth_2_key_manager_api_client/client.py
97 98 99 100 |
|
Client
A class for keeping track of data related to the API.
Attributes:
Name | Type | Description |
---|---|---|
base_url |
str
|
The base URL for the API, all requests are made to a relative path to this URL. |
cookies |
Dict[str, str]
|
A dictionary of cookies to be sent with every request. |
headers |
Dict[str, str]
|
A dictionary of headers to be sent with every request. |
timeout |
float
|
The maximum amount of a time in seconds a request can take. API functions will raise httpx.TimeoutException if this is exceeded. |
verify_ssl |
Union[str, bool, SSLContext]
|
Whether or not to verify the SSL certificate of the API server. This should be True in production, but can be set to False for testing purposes. |
raise_on_unexpected_status |
bool
|
Whether or not to raise an errors.UnexpectedStatus if the API returns a status code that was not documented in the source OpenAPI document. |
follow_redirects |
bool
|
Whether or not to follow redirects. Default value is False. |
Examples:
>>> from eth_2_key_manager_api_client.client import Client
>>> client = Client(base_url="http://localhost:7500")
>>> client.base_url
'http://localhost:7500'
Source code in eth_2_key_manager_api_client/client.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
get_headers()
Get headers to be used in all endpoints
Source code in eth_2_key_manager_api_client/client.py
51 52 53 |
|
with_cookies(cookies)
Get a new client matching this one with additional cookies
Source code in eth_2_key_manager_api_client/client.py
62 63 64 |
|
with_headers(headers)
Get a new client matching this one with additional headers
Source code in eth_2_key_manager_api_client/client.py
55 56 57 |
|
with_timeout(timeout)
Get a new client matching this one with a new timeout (in seconds)
Source code in eth_2_key_manager_api_client/client.py
69 70 71 |
|