// DOCUMENTATION

koko-fetch CLI

Fetch pages and structured extracts from the terminal without writing automation scripts.

Getting Started

koko-fetch is a CLI built on the Koko SDK. It connects to a running CDP server and fetches page HTML or structured extracts — useful for quick probes, CI checks, and shell pipelines.

Prerequisites

Koko must be reachable over CDP. Either launch from the SDK first, or start a server:

# Option A: SDK launch (see Quick start)
# Option B: long-lived server
koko serve --host 127.0.0.1 --port 9222

Fetch HTML

KOKO_CDP=http://127.0.0.1:9222 npx koko-fetch https://example.com

Default wait: domcontentloaded. HTML is written to stdout.

Structured extract (JSON)

KOKO_CDP=http://127.0.0.1:9222 npx koko-fetch \
  https://en.wikipedia.org/wiki/Earth --extract

The extract path uses the SDK page.extract() helper — optimized for crawler workloads with TTFX probe and structured fields (title, links, etc.).

Environment variables

VariableDescription
KOKO_CDPCDP HTTP endpoint (e.g. http://127.0.0.1:9222)

When to use SDK instead

  • Multi-step flows (login, form fill, click chains)
  • Agent APIs (semanticTree, NodeHandle)
  • Session state capture/restore
  • Profile launch via Browser.launch()