Skip to main content

lightpanda-py

panda

Lightpanda for Python, a fast headless browser for AI agents and web automation. Zero dependencies, browser included.

Fetch pages as HTML, Markdown or structured data, run scripts, let an AI agent browse, or start a CDP server for Playwright and Puppeteer and an MCP server for your agents.

Installation

uv add lightpanda-py

Example usage

import lightpanda

result = lightpanda.fetch("https://example.com", dump="markdown")
print(result.text)

Command line

The bundled browser is also available as the lightpanda command, with telemetry disabled by default:

lightpanda fetch --dump markdown https://example.com
lightpanda serve --host 127.0.0.1 --port 9222

Output formats

import lightpanda

html = lightpanda.fetch("https://example.com").text
markdown = lightpanda.fetch("https://example.com", dump="markdown").text
data = lightpanda.fetch("https://httpbin.org/ip").json()

# JSON-LD, OpenGraph, Twitter card and meta tags
meta = lightpanda.fetch("https://example.com", dump="structured_data").json()

# Text-only rendering as PNG or PDF
png = lightpanda.fetch("https://example.com", dump="png").bytes

Waiting and stripping

import lightpanda

# Wait for network idle, or for an element to appear
lightpanda.fetch("https://example.com", wait_until="networkidle")
lightpanda.fetch("https://example.com", wait_selector="h1", dump_selector="h1")

# Drop scripts and styles, or keep only the main content
lightpanda.fetch("https://example.com", strip_mode=["js", "css"])
lightpanda.fetch("https://example.com", dump="markdown", strip_mode="clutter")

Status and multiple URLs

json=True adds the HTTP status, headers and page diagnostics:

import lightpanda

status = lightpanda.fetch("https://example.com", dump="markdown", json=True).json()
print(status["http_status"], status["content"])

results = lightpanda.fetch(["https://example.com", "https://example.org"], dump="markdown").json()
for result in results["results"]:
    print(result["url"], result["http_status"])

Any CLI flag

Underscores become dashes, True adds a bare flag, and lists repeat the flag:

import lightpanda

result = lightpanda.fetch(
    "https://example.com",
    http_header=["Authorization: Bearer token"],  # --http-header ...
    user_agent_suffix="my-crawler",               # --user-agent-suffix my-crawler
    obey_robots=True,                             # --obey-robots
    cookie_jar="cookies.json",                    # --cookie-jar cookies.json
)

Errors raise lightpanda.Error; its message is the browser's stderr and .code the exit status. Pass fail_on_http_error=True to also raise on HTTP 4xx/5xx.

Using Playwright or Puppeteer

import lightpanda
from playwright.sync_api import sync_playwright

with lightpanda.serve(host="127.0.0.1", port=9222) as cdp, sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(cdp.endpoint)
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.content())
    browser.close()
import lightpanda

# Write logs to files
server = lightpanda.serve(stdout=open("lightpanda.out.log", "w"), stderr=open("lightpanda.err.log", "w"))

# CDP on / and WebDriver BiDi on /session, same port
server = lightpanda.serve(protocol=["cdp", "webdriver"])

# CDP over a Unix-domain socket instead of TCP
server = lightpanda.serve(unix_socket="/tmp/lightpanda.sock")

Running an MCP server

import lightpanda

with lightpanda.mcp() as mcp:
    print(mcp.request("tools/list"))  # list of available tools

# Or over HTTP, clients POST JSON-RPC to mcp.endpoint (http://127.0.0.1:8080/mcp)
with lightpanda.mcp(port=8080) as mcp:
    ...

Scraping examples

Self-contained uv scripts in examples/, no install needed:

  • hacker_news.py - extract the Hacker News front page into a list of stories with a PandaScript
  • quotes.py - click through a JavaScript-rendered, paginated site with Playwright
  • docs_to_markdown.py - fetch several pages as clean, size-capped Markdown for an LLM
  • ask_agent.py - let an AI agent browse a site and answer a question
uv run examples/hacker_news.py

# Or without cloning the repo
uv run https://raw.githubusercontent.com/tclesius/lightpanda-py/main/examples/hacker_news.py

Running tests

The bundled browser version is pinned in .browser-version. Download it for your platform, then run pytest:

scripts/get-browser lightpanda-x86_64-linux
uv run pytest

Available platforms:

  • lightpanda-aarch64-macos - macOS arm64 (default)
  • lightpanda-x86_64-macos - macOS x86_64
  • lightpanda-aarch64-linux - Linux arm64
  • lightpanda-x86_64-linux - Linux x86_64

License

MIT

Metadata

Release files for lightpanda-py 0.4.1

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

Built distributions (wheels)

Table of built distributions (wheels) for lightpanda-py 0.4.1
File Actions
lightpanda_py-0.4.1-py3-none-manylinux_2_38_aarch64.whl Python 3 none Linux glibc 2.38+ ARM64 Details for lightpanda_py-0.4.1-py3-none-manylinux_2_38_aarch64.whl
lightpanda_py-0.4.1-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details for lightpanda_py-0.4.1-py3-none-manylinux_2_35_x86_64.whl
lightpanda_py-0.4.1-py3-none-macosx_14_0_x86_64.whl Python 3 none macOS 14.0+ x86-64 Details for lightpanda_py-0.4.1-py3-none-macosx_14_0_x86_64.whl
lightpanda_py-0.4.1-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details for lightpanda_py-0.4.1-py3-none-macosx_14_0_arm64.whl

Total release size: 115.6 MB

Release files / lightpanda_py-0.4.1-py3-none-manylinux_2_38_aarch64.whl

Download URL lightpanda_py-0.4.1-py3-none-manylinux_2_38_aarch64.whl
Size 27.6 MB
Tags Linux glibc 2.38+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2ed17edba18b707bd058a1ad1c5ec8c7caf9fe01a3773f2f3ee11cf243e5de27
BLAKE2b-256 checksum
How to use checksums
994ddac7650782de7e859dbce6f223f33c50d1d99b0d7874e35832834d3f5e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / lightpanda_py-0.4.1-py3-none-manylinux_2_35_x86_64.whl

Download URL lightpanda_py-0.4.1-py3-none-manylinux_2_35_x86_64.whl
Size 29.1 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2ed1a9b8dc188df8da286d1e35469df23fd51c6872d30cfb823f20091a98e26c
BLAKE2b-256 checksum
How to use checksums
b7945c0059584d23d767682235b5daf85b25a4eb83142aa957818e2bc7d86e19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / lightpanda_py-0.4.1-py3-none-macosx_14_0_x86_64.whl

Download URL lightpanda_py-0.4.1-py3-none-macosx_14_0_x86_64.whl
Size 30.4 MB
Tags Python 3 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
58cae5fc0803f8d27e49ea8311ef76f7b456b2c1a29c1164e322bde35c50c927
BLAKE2b-256 checksum
How to use checksums
c97e22f3c750791a9a400cd658a0c131c2b1e78e19d075de7217f65102c69ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / lightpanda_py-0.4.1-py3-none-macosx_14_0_arm64.whl

Download URL lightpanda_py-0.4.1-py3-none-macosx_14_0_arm64.whl
Size 28.4 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
a6016e672d5835dc8366d79c93358b15f8917c8927234faa84ba3e48276e7a9b
BLAKE2b-256 checksum
How to use checksums
073ab0e5807850d6c6290a940bdfabd56aac722d161c3d00de359f92929bc590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for lightpanda-py 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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for lightpanda_py-0.4.1-py3-none-manylinux_2_38_aarch64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

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.

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