Run your first Fetch in seconds — from the CLI, a coding agent, the SDK, or the API.
Fetch a live page yourself, or give Expand to your coding agent. The human path starts with one command. The agent path starts with your harness integration.
Run one command in your terminal. Prints agent-ready Markdown for a live page, usually in seconds.
Give Fetch to Claude Code, Codex, Cursor, or OpenCode, then verify with one prompt.
The primary human command:
npx expandai fetchThis prints agent-ready Markdown for a live page. No project, no config.
The short
expandaiCLI package is pending publish. Until it is live, runnpx @expandai/cli fetch https://news.ycombinator.com. Thenpx expandai ...form above is the target command.
The primary agent prompt:
Use Expand to fetch https://news.ycombinator.com.
Show me the first 10 lines of Markdown and confirm the Fetch succeeded.If your agent does not have Expand yet, point it at setup first:
Read /start.md or the Expand Agent Quickstart for your harness, install the recommended integration, then run the verification Fetch.npx expandai fetch https://news.ycombinator.comOnce expandai is published under the short name:
npm install -g expandai
expandai fetch https://news.ycombinator.comIf the package is still scoped at install time, use the scoped name with the same binary:
npm install -g @expandai/cli
expandai fetch https://news.ycombinator.comLog in once and the CLI reuses your local session:
expandai login
expandai whoamiFor CI, servers, and non-interactive runs, set an API key instead. The CLI, SDKs, and direct API all read EXPAND_API_KEY:
export EXPAND_API_KEY="xpnd_..."Keep API keys server-side. Raw keys are shown only once after creation.
Markdown mode prints the readable page body. A Hacker News fetch starts like this:
# Hacker News
1. Example story title
2. Another story title
...When you want metadata and structured signal alongside the Markdown, request JSON mode:
expandai fetch https://news.ycombinator.com --format jsonObject-mode JSON carries:
markdown — Main Markdown for the page;meta.snapshotId — the reusable snapshot handle for replay and follow-up Highlights;Markdown mode does not print a snapshotId. Use --format json or an SDK fetchJson call when you need the snapshot handle.
These are secondary to the CLI for a first run, but they are the path into application code.
curl -X POST https://api.expand.ai/v1/fetch \
-H "x-expand-api-key: $EXPAND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://news.ycombinator.com"}'POST /v1/fetch returns Markdown.POST /v1/fetch/json returns object-mode JSON with Main Markdown, State JSON, and metadata.x-expand-api-key header. See API Reference and Output Model for exact schemas.Install @expandai/sdk. The client reads EXPAND_API_KEY from the environment.
import { ExpandClient } from "@expandai/sdk"
const client = new ExpandClient()
const markdown = await client.fetch({ url: "https://news.ycombinator.com" })
console.log(markdown)Use client.fetchJson({ url }) when you need Main Markdown, State JSON, and meta.snapshotId together. See the TypeScript SDK reference.
Install expandai and set EXPAND_API_KEY. The client opens as a context manager.
from expandai import Expand, FetchParams, FetchJsonParams
with Expand() as expand:
markdown = expand.fetch(FetchParams(url="https://news.ycombinator.com"))
print(markdown)Use expand.fetch_json(FetchJsonParams(url=...)) for Main Markdown plus State JSON and meta.snapshot_id. See the Python SDK reference.
The fastest way to give an agent web context is its native setup, not a paste. Pick your harness, install once, then verify.
| Agent | First path |
|---|---|
| Claude Code | Hook — also installs MCP |
| Codex | Skill + MCP |
| Cursor | Skill + MCP |
| OpenCode |
Hooks are available for Claude Code and OpenCode. Skill and MCP setup accept claude-code, cursor, opencode, and codex. Pi, Hermes, and OpenClaw are skill-based — set them up from Skill-Based Agents.
After setup, confirm the integration with one prompt:
Use Expand to fetch https://news.ycombinator.com.
Show me the first 10 lines of Markdown and confirm the Fetch succeeded.npx expandai not found: the short package is pending publish — use npx @expandai/cli fetch ... or install globally.expandai login, then expandai whoami to confirm.EXPAND_API_KEY, or send the x-expand-api-key header on direct API calls.--format json on the CLI or POST /v1/fetch/json.| Hook — also installs MCP |