Package: cirro_api_client
Cirro API ClientLow-level client for the Cirro API. Rather than using this package directly, we recommend using theCirro SDK.This Python package is automatically generated by theOpenAPI Python Clientproject.Requirements.Python 3.8+.Installation & Usagepip installVia PyPI:pipinstallcirro-api-clientYou can also install it directory from the repository using:pipinstallgit+https://github.com/CirroBio/Cirro-client-python.gitGetting StartedBasic usageimportosfromtypingimportListfrompprintimportpprintfromcirro_api_clientimportCirroApiClient,TokenAuthfromcirro_api_client.v1.api.projectsimportget_projectsfromcirro_api_client.v1.modelsimportProjectfromcirro_api_client.v1.typesimportResponse# Create auth method, you can also extend the AuthMethod classauth_method=TokenAuth(token=os.environ['TOKEN'])# You can also use the RefreshableTokenAuth class# auth_method = RefreshableTokenAuth(token_getter=lambda : os.environ['TOKEN'])# Create a clientclient=CirroApiClient(base_url="https://api.cirro.bio",auth_method=auth_method)# Call API endpoint, get list of projectsprojects:List[Project]=get_projects.sync(client=client)print("The response of get_projects:\n")pprint(projects)## or if you need more info (e.g. status_code)resp:Response[List[Project]]=get_projects.sync_detailed(client=client)projects=resp.parsedAsync usageimportosfromtypingimportListfromcirro_api_clientimportCirroApiClient,TokenAuthfromcirro_api_client.v1.api.projectsimportget_projectsfromcirro_api_client.v1.modelsimportProjectclient=CirroApiClient(base_url="https://api.cirro.bio",auth_method=TokenAuth(token=os.environ['TOKEN']))# async methodasyncwithclientasclient:projects:List[Project]=awaitget_projects.asyncio(client=client)Advanced usageThere are more settings on the generatedCirroApiClientclass which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlyinghttpx.Clientorhttpx.AsyncClient(depending on your use-case):importosfromcirro_api_clientimportCirroApiClient,TokenAuthdeflog_request(request):print(f"Request event hook:{request.method}{request.url}- Waiting for response")deflog_response(response):request=response.requestprint(f"Response event hook:{request.method}{request.url}- Status{response.status_code}")client=CirroApiClient(base_url="https://api.cirro.bio",auth_method=TokenAuth(token=os.environ['TOKEN']),httpx_args={"event_hooks":{"request":[log_request],"response":[log_response]}},)# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):importosimporthttpxfromcirro_api_clientimportCirroApiClient,TokenAuthclient=CirroApiClient(base_url="https://api.cirro.bio",auth_method=TokenAuth(token=os.environ['TOKEN']))# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.client.set_httpx_client(httpx.Client(base_url="https://api.cirro.bio",proxies="http://localhost:8030"))Developer informationRe-generate the API client by running:openapi-python-client.exeupdate--urlhttps://api.cirro.bio/openapi/cirro-data-latest.yml--configconfig.yml--custom-template-path=templates/