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.0.tar.gz (7.4 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.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: babelwrap-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 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.0.tar.gz
Algorithm Hash digest
SHA256 d0341a34927f1c548a3491eeadc36a2dfac24c42291dc73977dfbfcae8d68ec2
MD5 a079991b7f40fec984ee132a9d20ad8e
BLAKE2b-256 e810b7b2af2790de5a022cb66d6a2cb5c21f6c5a6c0930f1654daae0381b816a

See more details on using hashes here.

Provenance

The following attestation bundles were made for babelwrap-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: babelwrap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ee6a9b6597d1584bcffb866ac3891cf2f4cc5c665977ab1d170befc7effba9c
MD5 543269e9cd9fa6a5192151aa60aca50a
BLAKE2b-256 fdff31ee63b808c9275fb2bebd52ba48fe4b608e6db224d3d592d10c86068d8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for babelwrap-0.1.0-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