Skip to main content

bowmark-web

The Python client for the Bowmark capability library — the whole bowmark.* surface, running on our servers, with no Bowmark source on your disk.

Zero runtime dependencies, deliberately and permanently. urllib and json are the whole transport.

Requirements

  • Python 3.11 or newer. Python 3.10 and earlier are not supported.
# Check your Python version first
python3 --version   # must be 3.11 or higher

# Then install
pip install bowmark-web bowmark-web-stubs

You need an API key. Sign up at https://bowmark.ai/sign-up, create a key at https://bowmark.ai/dashboard/keys, and pass it in:

from bowmark_web import session

async with session(api_key="bmk_…") as bm:   # or set BOWMARK_API_KEY and omit it
    tracks = await bm.music.search("aphex twin")

A client with no key raises BowmarkError with code="no_api_key" on its first call, before anything is sent.

The second package is where the types live. PEP 561 requires a stub distribution to be named <pkg>-stubs, so the split is mandated rather than chosen. Skip it and the client still works; you just lose autocomplete for the catalog.

Two shapes, and the second one is the one you want

import asyncio
from bowmark_web import bowmark, session


async def main() -> None:
    # ONE call. Opens a one-shot session, runs it, closes it.
    tracks = await bowmark.music.search("aphex twin")

    # SEVERAL calls against ONE live instance — one browser, one cookie jar.
    async with session() as bm:
        found = await bm.music.search("burial", 5)
        detail = await bm.music.getTrack(found["tracks"][0]["url"])
        print(detail["track"]["description"])


asyncio.run(main())

A store flow is the same shape, and is where a shared instance actually earns its keep:

async with session() as bm:
    found = await bm.providers.gymshark.search({"query": "hoodie"})
    await bm.providers.gymshark.addToCart(
        {"variantId": found["products"][0]["variantId"]}
    )
    cart = await bm.providers.gymshark.getCart()   # itemCount is 1

A type checker will not know gymshark, and that is not a bug. Most sites are not listed in the generated types, so neither client's types enumerate them. The call works. Silence the checker with getattr(bm.providers, "gymshark") if you want a clean run.

bowmark.<unit>.<fn>() is wrong for a multi-step flow, and it fails quietly. Two calls get two instances and two cookie jars, so a cart the first filled does not exist for the second — a store's cart endpoint answers POST /cart/add.js with a 200 and the line echoed back, then reports item_count: 0. Reach for session() the moment a flow has a second step.

Each call inside a session is a round trip. Said out loud rather than hidden: a surface that looks like a local function call and is actually stateful is how an N+1 gets written without anyone noticing.

Configuration

Read at CALL time, not at import — so a .env loader that runs after your first import still works.

BOWMARK_API_KEY bmk_…. Required unless you pass api_key=. With neither, the first call raises code="no_api_key".
BOWMARK_API_URL Defaults to https://api.bowmark.ai.

Every entry point takes the same keyword overrides — api_key first, then base_url, headers, timeout, on_log.

Making raw HTTP calls without the SDK

If you need to call the API directly without using the client library, you must override Python's default urllib User-Agent header. The default Python-urllib/3.x is blocked by Cloudflare, which sits in front of our API. Set a custom User-Agent on every request:

import urllib.request
import json

url = "https://api.bowmark.ai/v1/session"
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
    "User-Agent": "bowmark-client",  # Required: override the default urllib User-Agent
}

request = urllib.request.Request(url, headers=headers, method="POST", data=json.dumps({}).encode())
with urllib.request.urlopen(request) as response:
    session = json.loads(response.read())

This requirement applies only to raw HTTP calls using urllib. The shipped client library handles this automatically. Any User-Agent header other than Python's default (e.g., "bowmark-client", "my-app/1.0", even "curl/7.0") works fine.

Errors

from bowmark_web import BowmarkError, BowmarkNeedsUserError

try:
    await bm.providers.linkedin.searchPeople({"query": "cto"})
except BowmarkNeedsUserError as paused:
    # NOT a failure. The call paused for a human login and the session is still open.
    print("sign in here:", paused.handoff["url"])
except BowmarkError as err:
    print(err.code, err.path)     # branch on `code`; `str(err)` is prose for a person

code is the field to branch on. str(err) is written for an agent to read, which is the wrong shape for an except block — both are present and neither replaces the other.

When your installed version is behind the live library, a typed call prints ONE line per function to stderr: [bowmark] … something changed in this function's provider since your version … (the call still runs), or [bowmark] … is no longer available … Update your version … (the call fails). The package sends its fingerprint of each function as x-bowmark-fn-digest so Bowmark can tell.

Two guards run before the request, not after

A bad argument is refused in your process, so it never costs a round trip and is never metered.

  • The wire guard refuses anything JSON cannot carry — a datetime, a set, a tuple, a class instance, a non-string dict key, an int past 2⁵³−1, a circular structure — and names the exact position: args[0].checkIn.
  • The shape guard refuses an argument the declared signature does not accept, from the same generated table the TypeScript client reads.

Both lean toward accepting. An object is open, an unmodelled type accepts anything, and a surplus argument is ignored — because a false refusal is a correct call rejected by your own client with no flag to turn it off, and a false accept costs one round trip.

Two consequences worth knowing:

  • An unknown FUNCTION on a known unit is refused, naming the manifest version. Upgrade the package, or use run(script), which is untyped by construction and reaches anything.
  • An unknown UNIT passes straight through. Most sites (bowmark.providers.gymshark.…) are deliberately not listed in the generated manifest.

run(script) — the string surface

from bowmark_web import run

envelope = await run('return await bowmark.music.search("burial")')
envelope["status"]   # "ok" | "error" | "partial" | "needs_user"

Returns the envelope rather than raising, because a script is composite: status, logs and result are read together. Untyped by construction — a string gets no checking, so the generated stubs cover session() and bowmark and never this.

A callable is refused before anything is sent: run(lambda: …) raises BowmarkError with code="run_not_a_string", naming session(). It used to come back as an envelope about raw HTTP bodies.

A polling run() passes idempotent=True, and only then is a connection reset that returns no response retried (three attempts in about a second). Use it only for a script that is safe to send twice: a read, a status poll, or a stop() of a session that may already be stopped.

polled = await run(f"return bowmark.browser_agent.status({id!r}, {{ waitMs: 45000 }})", idempotent=True)

login() is TYPED, but not yet wired here

Multi-account connections' packages/catalog/src/manifest.ts synthesizes a login() method (and a trailing { "connection": … } option on every signed-in one) for the manifest BOTH clients generate from, so bowmark_web-stubs types them for parity with the Node client. This runtime does not yet implement the credential lift login() needs: the Node client's transport (packages/bowmark-web/node/src/session.ts) lifts username/password/totpCode/totpSeed into a per-request x-bowmark-credential-<name> header before a login() call reaches the wire, because the server refuses a plain string in that position. Calling the typed login() method from this Python client today sends those fields as plain strings in the body and gets a clear CredentialError back — loud, not a silent leak, but not yet a working call. bm.connections.list/delete/update are Node-only for the same reason: neither is generated from the manifest, and neither has a Python-runtime counterpart yet.

Development

python3 -m unittest discover -s tests -t .

Stdlib only — no pip, no venv, no network — which is what lets this suite run inside the monorepo's hermetic CI gate. It is also the point of the package having no dependencies: a package that cannot be tested without installing something is one whose tests do not run.

bowmark_web/_validators.json and python-stubs/bowmark_web-stubs/__init__.pyi are GENERATED by pnpm run gen:public-types in the monorepo, from the same library manifest as the TypeScript .d.ts. Never edit them by hand. gate:public-types asserts the two languages type the same functions and fails a PR that breaks it; a stale copy is warned rather than failed, because every unit that lands anywhere staleens it and no branch can keep it true — regen-public-types.yml repairs that on main.

Metadata

Release files for bowmark-web 1.32.0

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

Source distribution (sdist)

Source distribution for bowmark-web 1.32.0
File Size Uploaded Provenance Actions
bowmark_web-1.32.0.tar.gz 318.3 kB Without provenance Details for bowmark_web-1.32.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bowmark-web 1.32.0
File Interpreter ABI Platform Actions
bowmark_web-1.32.0-py3-none-any.whl Python 3 none any Details for bowmark_web-1.32.0-py3-none-any.whl

Total release size: 651.6 kB

Release files / bowmark_web-1.32.0.tar.gz

Download URL bowmark_web-1.32.0.tar.gz
Size 318.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a8c59a17c543e261c3a8d7561c688f5efd9fda6e43cc4d1d4e758342e65e0f11
BLAKE2b-256 checksum
How to use checksums
193b0a91c1d806a9bbc521db965e476879b8f3661c08450e0c3db9a39c07b4d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bowmark_web-1.32.0-py3-none-any.whl

Download URL bowmark_web-1.32.0-py3-none-any.whl
Size 333.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dad9d4c46d667038528f607ddf07e432b26e90f306db3dd3a690cc52439b7442
BLAKE2b-256 checksum
How to use checksums
523d3376fe1af0ddc8154e75b6d9e7f1bbb13d70b3915437cddf4189fb873e92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for bowmark-web 1.32.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.

Release history Release notifications | RSS feed

This release

1.32.0 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