Skip to main content

A client library for accessing Cirro

Project description

Cirro API Client

Low-level client for the Cirro API. Rather than using this package directly, we recommend using the Cirro SDK.

This Python package is automatically generated by the OpenAPI Python Client project.

Requirements.

Python 3.10+.

Installation & Usage

pip install

Via PyPI:

pip install cirro-api-client

You can also install it directory from the repository using:

pip install git+https://github.com/CirroBio/Cirro-client-python.git

Getting Started

Basic usage

import os
from typing import List
from pprint import pprint

from cirro_api_client import CirroApiClient, TokenAuth
from cirro_api_client.v1.api.projects import get_projects
from cirro_api_client.v1.models import Project
from cirro_api_client.v1.types import Response

# Create auth method, you can also extend the AuthMethod class
auth_method = TokenAuth(token=os.environ['TOKEN'])
# You can also use the RefreshableTokenAuth class
# auth_method = RefreshableTokenAuth(token_getter=lambda : os.environ['TOKEN'])

# Create a client
client = CirroApiClient(base_url="https://api.cirro.bio",
                        auth_method=auth_method)

# Call API endpoint, get list of projects
projects: 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.parsed

Async usage

import os
from typing import List

from cirro_api_client import CirroApiClient, TokenAuth
from cirro_api_client.v1.api.projects import get_projects
from cirro_api_client.v1.models import Project

client = CirroApiClient(base_url="https://api.cirro.bio",
                        auth_method=TokenAuth(token=os.environ['TOKEN']))

# async method
async with client as client:
    projects: List[Project] = await get_projects.asyncio(client=client)

Advanced usage

There are more settings on the generated CirroApiClient class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying httpx.Client or httpx.AsyncClient (depending on your use-case):

import os
from cirro_api_client import CirroApiClient, TokenAuth

def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(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):

import os
import httpx
from cirro_api_client import CirroApiClient, TokenAuth

client = 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 information

Re-generate the API client by running:

openapi-python-client generate --overwrite --url http://localhost:8080/openapi/cirro-data-latest.yml --config config.yml --custom-template-path=templates/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cirro_api_client-1.5.0.tar.gz (127.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cirro_api_client-1.5.0-py3-none-any.whl (465.2 kB view details)

Uploaded Python 3

File details

Details for the file cirro_api_client-1.5.0.tar.gz.

File metadata

  • Download URL: cirro_api_client-1.5.0.tar.gz
  • Upload date:
  • Size: 127.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cirro_api_client-1.5.0.tar.gz
Algorithm Hash digest
SHA256 13f67e27ef19deb51dbf0037f34a78ab28cbbd75f45bf8cb11d13656b22f9188
MD5 b4f6ea72f4fc2477491156e01d29ac5a
BLAKE2b-256 8db774f1f5698f50b705a64a3617280220db0b47f074d42b8a4b1f157b50ed23

See more details on using hashes here.

Provenance

The following attestation bundles were made for cirro_api_client-1.5.0.tar.gz:

Publisher: package.yml on CirroBio/Cirro-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cirro_api_client-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cirro_api_client-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e3610b96360963fff7d54d7ff212b567f856d04d5bb22328f198c6bc5a2efe4
MD5 03e0e8fe86034a511305544421d27443
BLAKE2b-256 d58c96ed62b9a8cf4382a86a1c0127b5b4eb4ce09026707940632fa2ae438682

See more details on using hashes here.

Provenance

The following attestation bundles were made for cirro_api_client-1.5.0-py3-none-any.whl:

Publisher: package.yml on CirroBio/Cirro-client-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page