Skip to main content

Python SDK for the BabelWrap API — the web, as an API, for your agents.

Project description

BabelWrap Python SDK

The official Python client for the BabelWrap API — the web, as an API, for your agents.

BabelWrap lets AI agents interact with any website through a simple API. This SDK provides sync and async Python clients.

Installation

pip install babelwrap

Quick Start

from babelwrap import BabelWrap

with BabelWrap(api_key="bw_...") as bw:
    with bw.create_session() as session:
        snap = session.navigate("https://example.com")
        print(snap.title)

        # Interact with the page
        session.click("the Login button")
        session.fill("Email address field", "user@example.com")
        session.submit()

        # Extract structured data
        data = session.extract("all product names and prices")
        print(data)

Async Usage

from babelwrap import AsyncBabelWrap

async with AsyncBabelWrap(api_key="bw_...") as bw:
    async with await bw.create_session() as session:
        snap = await session.navigate("https://example.com")
        print(snap.title)

        data = await session.extract("all links on the page")

Features

  • Sync and async clients
  • Automatic retries with exponential backoff on transient errors
  • Context managers for automatic session cleanup
  • Typed snapshots with attribute access (snap.title, snap.inputs, snap.actions)
  • Site mapping — discover and generate tools for any website

API Reference

BabelWrap / AsyncBabelWrap

Method Description
create_session() Create a new browser session
usage() Get current usage statistics
health() Check API health
map_site(url) Map a website and generate tools
list_sites() List all mapped sites
site_tools(site_id) List tools for a mapped site
execute_tool(site_id, tool, params) Execute a generated site tool

Session / AsyncSession

Method Description
navigate(url) Navigate to a URL
click(target) Click an element
fill(target, value) Fill a form field
submit(target?) Submit a form
extract(query) Extract structured data
press(key) Press a keyboard key
scroll(direction, amount) Scroll the page
hover(target) Hover over an element
screenshot() Take a screenshot (base64 PNG)
upload(target, file_path) Upload a file
back() / forward() Browser history navigation
snapshot() Get current page state
wait_for(text?, selector?, url_contains?) Wait for a condition

Documentation

Full documentation at babelwrap.com/docs

License

MIT

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

babelwrap-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

babelwrap-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file babelwrap-0.1.1.tar.gz.

File metadata

  • Download URL: babelwrap-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for babelwrap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b3d0743c7df5cd09287082442ee62077346134d40272d5f97419c84d0e7bb163
MD5 a729195cc528a40d21a3c3957c55535f
BLAKE2b-256 82deb0a8c9a11828cb171da7d68c8ca453cf02dcabf25a222667000184cdb6ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for babelwrap-0.1.1.tar.gz:

Publisher: publish.yml on soulfir/babelwrap-monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file babelwrap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: babelwrap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for babelwrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8ed8ed8cbf896f814c8617d763f9571643a9406c96e5c3f69bd4a1984f30c3d
MD5 413417427df670a5a77ac8ec8b27780a
BLAKE2b-256 a1273179e5130e1a468d252cb7f1f341cdf7c451e9c619d8bdbdac0653f6d026

See more details on using hashes here.

Provenance

The following attestation bundles were made for babelwrap-0.1.1-py3-none-any.whl:

Publisher: publish.yml on soulfir/babelwrap-monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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