v2 Client

The v2 client is the actively maintained interface to the Flow API. If there is any functionality you’d like added, please create an issue on the GitHub repo.

Quick Start

Create a client, log in, and upload a sample:

from pathlib import Path
from flowbio.v2 import Client, UsernamePasswordCredentials

client = Client()
client.log_in(UsernamePasswordCredentials(
    username="alice", password="s3cret",
))

# See what sample types are available
for st in client.samples.get_types():
    print(f"{st.identifier}: {st.name}")

# Upload a sample
sample = client.samples.upload_sample(
    name="My RNA-Seq Sample",
    sample_type="RNA-Seq",
    data={"reads1": Path("reads_R1.fastq.gz")},
)
print(f"Created sample {sample.id}")
class flowbio.v2.Client(base_url='https://app.flow.bio/api', config=None)

Client for the Flow REST API.

Provides authentication and access to the Flow platform.

Usage:

from flowbio.v2 import Client
from flowbio.v2.auth import UsernamePasswordCredentials

client = Client()
client.log_in(UsernamePasswordCredentials(
    username="alice", password="s3cret",
))

If you are connecting to a private instance of Flow, you can pass that in the url parameter of the constructor:

client = Client(base_url="https://mycompany.flow.bio/api")
Parameters:
  • base_url (str) – The base URL of the Flow API. Defaults to "https://app.flow.bio/api".

  • config (ClientConfig | None) – Optional client configuration. If not provided, defaults are used.

property samples: SampleResource

Access sample-related operations (types, metadata, upload).

log_in(credentials)

Authenticate with the Flow API.

Delegates to the provided credentials strategy, which performs the authentication flow and stores the access token for subsequent requests.

Parameters:

credentials (Credentials) – The credentials to authenticate with. See flowbio.v2.auth for details.

Raises:

BadRequestError – If the credentials are invalid.

Return type:

None

class flowbio.v2.ClientConfig(chunk_size=1000000, show_progress=True, connection_retries=3)

Configuration for the Flow API client.

Parameters:
  • chunk_size (int) – Size of each upload chunk in bytes. Defaults to 1 MB.

  • show_progress (bool) – Whether to display progress bars during file uploads. Defaults to True.

  • connection_retries (int) – Number of times to retry on connection failure (e.g. ConnectError, ConnectTimeout). Only retries when the TCP connection was never established, so it is safe for all HTTP methods including POST. Set to 0 to disable. Defaults to 3.

Example usage:

from flowbio.v2 import Client, ClientConfig

client = Client(config=ClientConfig(
    chunk_size=5_000_000,
    show_progress=False,
))