Skip to main content
The zenrows CLI wraps every Zenrows primitive in one command, writes clean output to stdout and progress to stderr, and keeps a trace of every run. That makes it a natural fit for shell scripts, jq pipelines and cron jobs. Uses: zenrows fetch, zenrows extract, zenrows batch, zenrows crawl, zenrows browser, traces

Ask your AI agent

With the Zenrows MCP server connected, or the CLI available to a coding agent such as Claude Code, paste this prompt:

Install and log in

Install the CLI once, then set up a workspace with your API key. zenrows init creates the local .zenrows/ folder that holds your config, policy and run traces.
CLI
In CI or containers, export the key instead and tell the CLI to read it:
CLI

Fetch and extract into jq

zenrows fetch and zenrows extract use Adaptive Stealth Mode (mode=auto) by default. The page body goes to stdout and the status line goes to stderr, so pipes stay clean. zenrows extract returns structured JSON, so you can pipe it straight into jq. With --css, you name the fields and their selectors:
CLI
Without --css, zenrows extract sends extract=auto for site-tailored fields on domains Zenrows has prepared, such as major retailers, and uses Autoparse on other domains. Save any page as markdown with --output markdown and --out:
CLI

Script with —json

Every command accepts --json and prints a structured result instead of the body or the status line. Use it to branch on status or log cost in a script:
CLI

Run a URL list as one Batch job

For tens to thousands of URLs, submit them as one Batch job instead of a loop of fetches. The CLI reads a JSONL file with one {"url": ...} object per line.
1

Build the job file from a plain URL list

CLI
2

Estimate the cost locally

estimate validates the file and prints an upper bound, with no cloud call and no credits spent. Tasks in Adaptive Stealth Mode count at their highest possible cost.
CLI
3

Submit and wait for the run

--follow polls until the run finishes. --output markdown sets the format of every result.
CLI
4

Download every result

CLI
pages/ gets one file per task plus _manifest.jsonl, which maps each file to its URL and status:
The run above billed 3 credits in total: the estimate is a ceiling, and mode=auto bills only the configuration that succeeds. Check the real spend with zenrows batch status <job-id> --json, which returns stats.spend.credits.

Crawl a site, then batch what you found

zenrows crawl create discovers URLs from one start page. Feed the results straight into a Batch job:
CLI
Including /page/ lets the crawl walk the paginated listing, and the jq filter keeps only product URLs (88 of the 100 in this run). See Crawl from a seed URL for more patterns.

Drive a browser from the shell

When a page needs clicks or typing, open a Browser session. Each verb takes the --session id that open returns. Always close the session when you finish.
CLI
For longer flows, put the steps in a JSON file and run them with zenrows browser run script.json, which closes the session for you. See the Browser CLI guide.

Schedule it with cron

The CLI keeps your key and policy in .zenrows/, so a cron job only needs to run from that folder. This script refreshes the product pages every morning:
scrape.sh
crontab
For schedules that run on Zenrows’ side with no machine of your own, see Run scraping jobs on a schedule.

Read a run’s trace

Every fetch, extract, batch, crawl and browser run writes a record under .zenrows/runs/<run-id>/. The run id is in the status line (run r-1a9dfd1e).
CLI
trace inspect prints the full record as JSON, including the exact request parameters and costCredits. trace replay prints the command to run it again.

Customize it

Troubleshooting

  • AUTH_MISSING: no key in this workspace. Run zenrows login --api-key YOUR_ZENROWS_API_KEY from the project folder.
  • No workspace found on trace: traces live in .zenrows/. Run zenrows init --yes in the project folder, then run the command again.
  • PARAM_CONFLICT_AUTO_MANUAL: --js-render or --premium-proxy on fetch or extract needs --manual. Add it, or drop those flags to keep mode=auto.
  • POLICY_LIMIT_EXCEEDED on batch create: the estimate is above your max_credits_per_run. Split the file or raise the cap with zenrows policy set max_credits_per_run <n>.
  • The cron job finds no key: cron starts in your home folder. cd into the project folder first, as in the script above.
  • The cron job reports zenrows: command not found: cron runs with a minimal PATH. Call the CLI by its full path, which which zenrows prints.
More codes and fixes: CLI troubleshooting.

Scrape a list of URLs

Batch from the API and SDKs, with webhooks and reruns.

Prompts that put Zenrows MCP to work

The same jobs, done by your AI agent.

Track usage and control spend

Read per-request cost and set caps.

Resolve common response codes

Symptom-to-fix for 422, 429, 402 and more.