PyStreamCI
Python client library for StreamCI — a connector-style API in the spirit of database drivers.
Installation
pip install pystreamci
# or editable install for development
pip install -e clients/python/
Quick Start
from pathlib import Path
import pystreamci
# Secret-key auth (recommended) — use as context manager.
# `project` is the database; `datastore` is optional (defaults to the
# project's default datastore).
with pystreamci.connect("https://api.streamci.org",
project="climate",
datastore="temperature",
secret_key="...") as client:
# Insert a document
client.insert({"time": {"$date": "2025-08-04T10:00:00Z"}, "val": 42})
# Insert many documents (auto-batched)
client.insert_many(records, batch_size=1000)
# Upload an NDJSON/CSV file
client.insert_file("data.ndjson")
# Query (returns list of dicts)
docs = client.query({"val": {"$gte": 10}}, sort={"time": 1}, limit=50)
# Stream large results with an iterator
for doc in client.query_iter({"val": {"$gte": 0}}):
process(doc)
# Download a blob field
blob = client.query_blob(document_id="67abc...", field="image1")
# Download blob fields from multiple documents
blobs = client.query_blobs_by_field(["67abc...", "89def..."], field="image1")
# Download all blob fields from a single document
all_blobs = client.query_blobs_by_doc(document_id="67abc...")
# Insert with blob attachment — flexible formats accepted
client.insert({"name": "doc"}, blobs={"photo": "/path/to/photo.jpg"}) # file path
client.insert({"name": "doc"}, blobs={"photo": Path("photo.jpg")}) # Path object
with open("photo.jpg", "rb") as f:
client.insert({"name": "doc"}, blobs={"photo": f}) # file object
client.insert({"name": "doc"}, blobs={"photo": ("photo.jpg", f)}) # 2-tuple
client.insert({"name": "doc"}, blobs={"photo": ("photo.jpg", f, "image/jpeg")}) # 3-tuple
# Update and delete
client.update({"val": 42}, {"val": 43})
client.delete({"val": 43})
# Password auth
client = pystreamci.connect("https://api.streamci.org",
project="climate",
username="user1", password="pass123")
API Reference
pystreamci.connect(host, project, *, target=None, secret_key=None, username=None, password=None, datastore=None, max_retries=3, timeout=30.0, log_level="WARNING", log_file=None)
Returns a StreamCIClient. Auth type is inferred from the provided credentials.
Addressing:
project— the project (database) name. First positional arg, soconnect(host, "climate", ...)works.datastore— optional; a specific datastore within the project. When omitted, the server uses the project's default datastore (legacy-compatible).target— deprecated alias forproject(pre-0.5 argument name), still accepted. Pass one ofproject/target, not both.
StreamCIClient
| Method | Description |
|---|---|
insert(data, blobs=None) |
Insert a single document (with optional blob attachments) |
insert_many(data, datatype, batch_size) |
Batch insert (auto-splits at batch_size) |
insert_file(file_path, datatype) |
Upload NDJSON/CSV file |
update(filter, data, blobs=None) |
Update matching documents |
delete(filter) |
Delete matching documents |
query(query, *, project, sort, limit) |
Query and return list |
query_iter(query, *, project, sort, limit) |
Query with streaming iterator |
query_blob(document_id, field) |
Download blob field as bytes |
query_blobs_by_field(document_ids, field) |
Download blob field from multiple documents |
query_blobs_by_doc(document_id, *, ignore_errors) |
Download all blob fields from a document (including nested blob fields); returns dot-notation keys |
pystreamci.make_date(dt)
Convert a datetime or ISO-8601 string to a StreamCI {"$date": "..."} object.
pystreamci.make_date("2025-08-04T10:00:00Z")
pystreamci.make_date(datetime(2025, 8, 4, 10, 0, tzinfo=timezone.utc))
Exceptions
| Exception | When raised |
|---|---|
StreamCIConnectionError |
Connection failed after retries |
StreamCIAuthError |
Authentication/authorization error (subclass of StreamCIRequestError) |
StreamCIRequestError |
Server returned status=0 |
StreamCIParseError |
Response parsing failed |
StreamCITimeoutError |
Request timed out |
StreamCIValidationError |
Invalid client-side input |
query() vs query_iter()
| Method | Returns | Use when |
|---|---|---|
query(...) |
list[Document] |
Result fits in memory; need random access |
query_iter(...) |
Iterator[Document] |
Large result sets; process one doc at a time |
query_iter() uses HTTP streaming (stream=True) and parses NDJSON line-by-line, keeping memory usage constant regardless of result size.
Metadata
Release files for pystreamci 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pystreamci-0.5.0.tar.gz | 15.3 kB | Without provenance | Details for pystreamci-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pystreamci-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pystreamci-0.5.0-py3-none-any.whl |
Total release size: 33.8 kB
Release files / pystreamci-0.5.0.tar.gz
| Download URL | pystreamci-0.5.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
115d4f3efcaebeac7e34b8ac13937380d30713a80bf82c26a1f89b4c15c18d4e
|
|
BLAKE2b-256 checksum How to use checksums |
297bf3844926d70b02b8691f50ff9a18b47b32f3bdc241bccaf3baf2b76c978b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / pystreamci-0.5.0-py3-none-any.whl
| Download URL | pystreamci-0.5.0-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01bfff56710d4be40f56806a34b19733cd788a25b0da4c6dff279f6dd8883bd1
|
|
BLAKE2b-256 checksum How to use checksums |
a216270d14dbd055f5a621098730f8147eaafdc4c2816710052aadca0fece99d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for pystreamci 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.