Skip to main content

BytesMap for Python

The official Python 3.11+ SDK for the BytesMap workspace API and append-only event ingestion. It has no runtime dependencies and uses the standard library with verified TLS. All 240 API methods are generated from BytesMap's shared operation catalogue, with Python names and keyword arguments.

pip install bytesmap

Send events

Create a dataset and an ingestion key in Events → Connect application. Set BYTESMAP_EVENTS_URL, BYTESMAP_EVENT_DATASET, and BYTESMAP_EVENT_TOKEN, then:

import os
from bytesmap import EventClient

with EventClient(
    endpoint=os.environ["BYTESMAP_EVENTS_URL"],
    dataset=os.environ["BYTESMAP_EVENT_DATASET"],
    token=os.environ["BYTESMAP_EVENT_TOKEN"],
    namespace="production",
    group="application",
) as events:
    accepted = events.emit("app.started")
    # Declare durationMs on the dataset before sending this dimension.
    events.emit(
        "request.finished", dimensions={"durationMs": 120}, data={"route": "/orders"}
    )

emit() waits for durable acceptance. There is no background buffer or shutdown flush. IDs, UTC timestamps and schema version 1 are supplied automatically. events.scope(dimensions={"userId": "user_42"}) snapshots request context while sharing the transport. Declare dimension names and types on the dataset first; full JSON belongs in data. Pass error=exception to capture its name, message, stack and explicit cause.

Use send([EventDraft("app.started"), ...]) for a batch. Limits match the server: 1,000 events, 1 MiB per batch, 64 dimensions and 64 KiB of dimensions/data per event. Numbers must fit the JavaScript safe range. HTTPS is required. Local testing on HTTP loopback requires explicit allow_plaintext_loopback=True.

Network errors, HTTP 408/429/5xx and invalid acceptance receipts retry with the same batch identity and bytes (default five attempts). Other HTTP errors fail immediately. EventDeliveryError.batch returns the original payload for events.retry(error.batch). An unconfirmed send may already have been accepted; preserve its batch identity when retrying. Retry-After above one minute returns retry_later so the application can schedule its retry.

Workspace API

import os
from bytesmap import BytesMapClient, CallOptions

with BytesMapClient(
    base_url="https://api.example.com",
    token=os.environ["BYTESMAP_API_TOKEN"],
    project_id="project-id",
) as client:
    dashboards = client.dashboards.list()
    result = client.queries.run(id="saved-query-id")
    workspace = client.scope("workspace-id")
    workspace.sources.list(call_options=CallOptions(project_id="another-project"))

API and event ingestion keys are separate credentials. Keep workspace API keys on your server. Scopes cannot widen a key's server-enforced permissions. Modules and methods use snake_case (client.event_destinations.list()); keyword arguments are mapped to the wire contract's field names (destination_id → destinationId). Pass a dictionary with original wire field names for nested payloads:

client.dashboards.update({"id": "dashboard-id", "folderId": None})
client.invoke("queries.run", {"id": "saved-query-id", "params": {"customer": "id"}})

Omitted fields stay omitted; None sends explicit JSON null. Methods return public JSON values (dicts, lists and scalars). BytesMapError exposes code, params and status; its string representation contains only the error code. Export methods return filename, contentType and contentBase64.

API mutations are never automatically retried. All requests reject redirects and use a finite timeout. A token callback supports rotating credentials; a project_id callback supports current project selection. Project selection is captured before the token callback. Closing a scope never closes its parent; closing the parent makes its scopes unavailable.

Clients are synchronous. In async applications, use asyncio.to_thread around calls; cancelling that await does not cancel the underlying HTTP request, which remains bounded by its timeout. An optional transport implementing the exported Transport protocol supports host-owned HTTP clients and tests; the caller owns its lifetime and must disable redirects and retain TLS verification.

Development

bun --no-env-file scripts/generate-python-sdk.ts
bun --no-env-file scripts/generate-python-sdk.ts --check
PYTHONPATH=packages/python/src python3 -m unittest discover -s packages/python/tests -v
python3 -m build packages/python

Generated catalogue files are committed. Regenerate them when the shared operation catalogue or event limits change. Python releases are independent of npm and NuGet.

Metadata

Release files for bytesmap 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bytesmap 0.1.1
File Size Uploaded Provenance Actions
bytesmap-0.1.1.tar.gz 25.8 kB Without provenance Details for bytesmap-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bytesmap 0.1.1
File Interpreter ABI Platform Actions
bytesmap-0.1.1-py3-none-any.whl Python 3 none any Details for bytesmap-0.1.1-py3-none-any.whl

Total release size: 51.0 kB

Release files / bytesmap-0.1.1.tar.gz

Download URL bytesmap-0.1.1.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
11047ae7c5056a2eb1aef65a08f7fa569a511e1f7d1b36d1687f19f49dc77d49
BLAKE2b-256 checksum
How to use checksums
b3649afa370390bf33ef475cc93661bbc6ea40895b25a357ac9b57f692a440d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / bytesmap-0.1.1-py3-none-any.whl

Download URL bytesmap-0.1.1-py3-none-any.whl
Size 25.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7172aae2c2f5956ad93d38367e5dda76df599c1554f0fd282d84282af21864ae
BLAKE2b-256 checksum
How to use checksums
c7d95ee347b7ecc88f8e5233069dbfde5c3a18c8aeb59d7689dc5567af17acdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for bytesmap 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page