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.8+.

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.v1 import CirroApiClient
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 a client
client = CirroApiClient(base_url="https://api.cirro.bio",
                        token=os.environ['TOKEN'])

# 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.v1 import CirroApiClient
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",
                        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.v1 import CirroApiClient

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",
    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.v1 import CirroApiClient

client = CirroApiClient(base_url="https://api.cirro.bio",
                        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.exe update --url https://api.cirro.bio/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-0.0.5.tar.gz (45.9 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-0.0.5-py3-none-any.whl (155.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cirro_api_client-0.0.5.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure

File hashes

Hashes for cirro_api_client-0.0.5.tar.gz
Algorithm Hash digest
SHA256 60e419f6469146da36d059d945866472307323e8f7cb1642d7ce1641436b6820
MD5 e3ddbfe74e623391af932ea020d9474e
BLAKE2b-256 b7037b32021bfe8e5b4b0fe034638cb20249038f04fd506c826138d8e8387aaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cirro_api_client-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 155.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure

File hashes

Hashes for cirro_api_client-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 44053949567cb4cdb0058994f998bd38f9c583a0ee5101989ed54bcb2f68dd52
MD5 9a55c623f8c97abb9a1a68e974cb0c61
BLAKE2b-256 039fd231fc08edf6f21194d0f577fd78d11792acaba5cc6cf4f8b04e358fad03

See more details on using hashes here.

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