Skip to main content

Python SDK for the Web Speed API — machine-readable maps of any web page for AI agents.

Project description

Web Speed — Python SDK

The machine-readable layer for the web. Give your AI agent a clean, structured map of any page — what it is, what's on it, and what it can do (search, add-to-cart, log in, paginate) — instead of dumping raw HTML or screenshots.

pip install webspeed

Quickstart

from webspeed import WebSpeed

ws = WebSpeed(api_key="wsp_...")          # or set the WEBSPEED_API_KEY env var

page = ws.map("https://example.com/product")
print(page["page_type"])                   # e.g. "product"
for action in page.get("actions", []):     # what the agent can do here
    print(action["intent"], action["selector"])   # e.g. "add_to_cart" "#add-btn"

That's the whole integration. Get a key at https://getwebspeed.io.

What you can call

ws.map(url, js=None, fresh=False, max_age=None)   # structured map of a page
ws.site_map(root_url, max_pages=25)               # crawl + combined map
ws.extract(html, base_url="")                     # map raw HTML you already have
ws.click(url, selector)                           # click, return the resulting map
ws.fill_and_submit(url, fields, submit_selector=None)
ws.submit_form(url, method="GET", fields={...})
ws.evaluate(url, js)                              # run JS, return the result
ws.inspect(url, selector)                         # structured data for a selector
ws.usage()                                        # credit balance + lifetime usage

js=None lets your account default decide; pass js=True for SPA/React sites.

Errors are typed

from webspeed import (
    WebSpeedError, AuthError, PaymentRequiredError, RateLimitError,
    FetchError, NetworkError,
)

try:
    page = ws.map("https://example.com")
except PaymentRequiredError as e:
    print("Out of credits / over plan limit:", e.code)   # e.g. "out_of_credits"
except FetchError as e:
    print("The target page couldn't be mapped (you're not charged):", e.code)
except WebSpeedError as e:
    print("API error:", e.status, e.message)

Transient errors (429 / 5xx / network) are retried automatically with backoff.

Use it as an agent tool

OpenAI / Anthropic function-calling:

from webspeed import WebSpeed, tools

ws = WebSpeed()
resp = openai_client.chat.completions.create(
    model="gpt-4o", messages=[...], tools=tools.openai_tools(),
)
# when the model calls a tool:
result = tools.call_tool(ws, tool_call.function.name,
                         json.loads(tool_call.function.arguments))

LangChain:

from webspeed import WebSpeed, tools
agent_tool = tools.make_langchain_tool(WebSpeed())   # pip install 'webspeed[langchain]'

Notes

  • Auth is sent as a header (X-Web-Speed-Key) — your key never appears in a URL.
  • Works with any MCP-less stack. (For MCP-native hosts like Claude/Cursor, add the Web Speed MCP server instead — same engine, zero code.)

Docs: https://api.getwebspeed.io/docs

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

webspeed-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

webspeed-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webspeed-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for webspeed-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af7493ad5d5095d20e326f1a1fcae732022cc9880115c330a57319eec7dc9059
MD5 7ce7b206c46a65249573e944daef2731
BLAKE2b-256 57aed9135aad21610211872ebaa93c67351d0b5fba3324cb800ffdb513f8875c

See more details on using hashes here.

File details

Details for the file webspeed-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: webspeed-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for webspeed-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 176dc1ea8899cae8bcc74d1fc79b24d1070647aeda9accb4d140b86b1580f5c8
MD5 faf6d0340752f82fc9c361ccf7c311f8
BLAKE2b-256 dccfab02da8a3bbe7d5bbac1eb5bde78a138aff7b414809ef118d23f8f3a0311

See more details on using hashes here.

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