Minimalist Python client for the Iris API, built on top of Authlib and httpx.
pip install dioptra-iris-clientfrom iris_client import IrisClient, AsyncIrisClient
base_url = "https://api.iris.dioptra.io"
username = "[email protected]"
password = "password"
# Synchronous client
with IrisClient(base_url, username, password) as client:
measurements = client.get("/measurements/").json()
# Asynchronous client
async with AsyncIrisClient(base_url, username, password) as client:
measurements = (await client.get("/measurements/")).json()
# Helper function to fetch all the results from a paginated endpoint,
# available for both clients:
all_measurements = client.all("/measurements/")The Iris client looks for credentials in a way similar to the AWS SDK:
- If one of
base_url,usernameorpasswordis specified, these values will be used. - If none of the previous values are specified, and one of
IRIS_BASE_URL,IRIS_USERNAMEorIRIS_PASSWORDenvironment variables are present, these values will be used. - If none of the previous values are specified, and the file
~/.config/iris/credentials.jsonexists, the fieldsbase_url,usernameandpasswordwill be used.