plasmate
Agent-native headless browser for Python. HTML in, Semantic Object Model out.
Install
pip install plasmate
Requires the plasmate binary in your PATH:
curl -fsSL https://plasmate.app/install.sh | sh
Quick Start
from plasmate import Plasmate
browser = Plasmate()
# Fetch a page as a structured Semantic Object Model
som = browser.fetch_page("https://news.ycombinator.com")
print(f"{som['title']}: {len(som['regions'])} regions")
# Extract clean text only
text = browser.extract_text("https://example.com")
print(text)
# Interactive browsing
session = browser.open_page("https://example.com")
print(session["session_id"], session["som"]["title"])
title = browser.evaluate(session["session_id"], "document.title")
print(title)
browser.close_page(session["session_id"])
browser.close()
Async
from plasmate import AsyncPlasmate
async with AsyncPlasmate() as browser:
som = await browser.fetch_page("https://example.com")
print(som["title"])
Context Manager
with Plasmate() as browser:
som = browser.fetch_page("https://example.com")
# Process closes automatically
API
Plasmate(binary="plasmate", timeout=30)
| Param | Type | Default | Description |
|---|---|---|---|
binary |
str |
"plasmate" |
Path to the plasmate binary |
timeout |
float |
30 |
Response timeout in seconds |
Stateless (one-shot)
fetch_page(url, *, budget=None, javascript=True)- Returns SOM dictextract_text(url, *, max_chars=None)- Returns clean text string
Stateful (interactive sessions)
open_page(url)- Returns dict withsession_idandsomevaluate(session_id, expression)- Run JS, get resultclick(session_id, element_id)- Click element, get updated SOMclose_page(session_id)- Close session
Lifecycle
close()- Shut down the plasmate process
Pydantic Models
Parse SOM responses into typed Pydantic v2 models:
from plasmate import Plasmate, Som, find_interactive, find_by_text, flat_elements
browser = Plasmate()
data = browser.fetch_page("https://example.com")
som = Som(**data)
print(som.title) # "Example Domain"
print(som.meta.element_count) # 12
for region in som.regions:
print(f"{region.role}: {len(region.elements)} elements")
Query Helpers
Search and traverse SOM documents:
from plasmate import Som, find_by_role, find_by_id, find_by_tag
from plasmate import find_interactive, find_by_text, flat_elements, get_token_estimate
# Find all navigation regions
navs = find_by_role(som, "navigation")
# Find a specific element
el = find_by_id(som, "e5")
if el:
print(el.role, el.text)
# Find all links
links = find_by_tag(som, "link")
# Get all interactive elements (buttons, inputs, etc.)
for el in find_interactive(som):
print(f"{el.id}: {el.role} - {el.text}")
# Search by text content (case-insensitive)
results = find_by_text(som, "sign up")
# Flatten all elements for iteration
all_elements = flat_elements(som)
print(f"{len(all_elements)} total elements")
# Estimate token usage
tokens = get_token_estimate(som)
print(f"~{tokens} tokens")
How It Works
The SDK spawns plasmate mcp as a child process and communicates via JSON-RPC 2.0 over stdio. The plasmate binary handles HTML parsing, JavaScript execution (V8), and SOM compilation in Rust.
License
Apache-2.0
Metadata
Release files for plasmate 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plasmate-0.4.1.tar.gz | 11.1 kB | Without provenance | Details for plasmate-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plasmate-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for plasmate-0.4.1-py3-none-any.whl |
Total release size: 19.8 kB
Release files / plasmate-0.4.1.tar.gz
| Download URL | plasmate-0.4.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4eb308f2ed26369541beb10a4567871d069f24eabc6d4aa7bce310c5e7cff29f
|
|
BLAKE2b-256 checksum How to use checksums |
a76404c2e01848ef90229b87aeafdecf39df5871ab7c297d256d500193cf64b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / plasmate-0.4.1-py3-none-any.whl
| Download URL | plasmate-0.4.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32c9e3c4d0c4e2d8e8636749dd1025f7ae5b22439a1389827ea6aa00a1880964
|
|
BLAKE2b-256 checksum How to use checksums |
012d486431baa8b17c4607ebe6b7014c68037161325a8583865577392f80ebce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for plasmate 0.4.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.