npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

scraperapi-cli

v1.0.0

Published

Official CLI for ScraperAPI — scrape any URL, run async jobs, extract structured data, and manage crawls from your terminal.

Downloads

135

Readme

ScraperAPI CLI

The official command-line interface for ScraperAPI. Scrape any URL, run async jobs, extract structured data, manage crawls and pipelines — all from your terminal.

Installation

Requires Node.js 18 or higher.

npm install -g scraperapi-cli

Installing from source (until the package is published to npm):

git clone https://github.com/scraperapi/scraperapi-cli
cd scraperapi-cli
npm install
npm run build
npm link

npm link creates a global sapi symlink pointing at your local build. Re-run npm run build after any source changes.

Quick Start

# 1. Configure your API key (from https://dashboard.scraperapi.com)
sapi init

# 2. Scrape a page
sapi scrape https://example.com

# 3. Pipe output into another tool
sapi scrape https://example.com --json | jq .statusCode

Authentication

sapi looks for your API key in this order:

  1. --api-key <key> flag on any command
  2. SCRAPERAPI_API_KEY environment variable
  3. Config file written by sapi init (~/.config/scraperapi/config.json)

Get your API key from the ScraperAPI dashboard. New accounts include a free trial with 5,000 credits.


Commands

sapi init

Interactive setup. Prompts for your API key, validates it, and saves it to the config file.

sapi init
# or non-interactively:
sapi init --api-key YOUR_KEY

sapi scrape <url>

Scrape a URL synchronously and print the response body. See the supported parameters reference for full details on all options.

sapi scrape https://example.com
sapi scrape https://example.com --render          # JavaScript rendering
sapi scrape https://example.com --render --wait-for "#main"
sapi scrape https://example.com --country gb      # UK IP
sapi scrape https://example.com --premium         # residential proxies
sapi scrape https://example.com --autoparse --json
sapi scrape https://example.com --async           # submit as background job

| Flag | Description | | ------------------ | ---------------------------------------------- | | --render | JavaScript rendering | | --premium | Residential proxies | | --ultra-premium | Advanced anti-bot bypass | | --screenshot | Capture PNG screenshot | | --autoparse | Return structured JSON | | --country <cc> | Geotarget (ISO 3166-1, e.g. us, gb, de) | | --device <type> | mobile or desktop user-agent | | --output <fmt> | html, markdown, text, json, csv | | --session <n> | Sticky session (reuse same IP) | | --wait-for <sel> | CSS selector to wait for (requires --render) | | --timeout <sec> | Request timeout in seconds (default: 70) | | --async | Submit as async job, print job ID and exit | | --json | Output raw JSON to stdout |

Some flags incur additional credit costs per request. See the supported parameters reference for the full breakdown.


sapi cost <url>

Check the credit cost of a scrape request without executing it. Accepts the same flags as sapi scrape (except --async and --timeout).

sapi cost https://example.com
sapi cost https://example.com --render --premium
sapi cost https://example.com --render --json

Prints the number of credits the request would consume:

25 credits

sapi jobs

Manage async scrape jobs. Use these when scraping large volumes or when you don't need an immediate response.

sapi jobs list                        # list all jobs
sapi jobs get <jobId>                 # poll until done, print result
sapi jobs get <jobId> --no-poll       # fetch current status without polling
sapi jobs cancel <jobId>              # cancel a running job
sapi jobs batch urls.txt              # submit up to 50,000 URLs from a file

urls.txt should contain one URL per line. See the batch requests docs for more on bulk submission.


sapi structured

Fetch pre-parsed structured data from supported platforms — no need to write a parser. See the Structured Data Endpoints docs for response schemas and supported options.

Amazon

sapi structured amazon product https://amazon.com/dp/B09XYZ
sapi structured amazon search "wireless headphones"
sapi structured amazon offers https://amazon.com/dp/B09XYZ
sapi structured amazon reviews https://amazon.com/dp/B09XYZ

Google

sapi structured google serp "best espresso machine"
sapi structured google news "artificial intelligence"
sapi structured google jobs "software engineer remote"
sapi structured google shopping "standing desk"
sapi structured google maps "coffee shops near me"

Walmart / eBay / Redfin

sapi structured walmart product https://walmart.com/ip/123456
sapi structured ebay product https://ebay.com/itm/123456
sapi structured redfin listing https://redfin.com/home/12345
sapi structured redfin search "Austin TX"
sapi structured redfin agents "Portland OR"

All structured commands support --json for raw JSON output.


sapi crawler

Crawl an entire domain and collect all discovered URLs. See the Crawler docs for configuration options and job lifecycle details.

sapi crawler start example.com          # start a crawl
sapi crawler status <jobId>             # check progress
sapi crawler results <jobId>            # list discovered URLs
sapi crawler results <jobId> --json     # as JSON array

sapi pipeline

Manage DataPipeline bulk scraping projects. DataPipeline handles scheduling, retries, and result storage for large-scale recurring jobs.

sapi pipeline list                      # list your projects
sapi pipeline run <projectId>           # trigger a run
sapi pipeline status <jobId>            # check run status
sapi pipeline results <jobId>           # fetch results

sapi account

Inspect your account usage and manage API keys. Credit usage and limits are also visible in the ScraperAPI dashboard.

sapi account                            # show credits and usage
sapi account keys list
sapi account keys create
sapi account keys revoke <keyId>

sapi config

Read and write config defaults without re-running sapi init.

sapi config list
sapi config get api_key
sapi config set default_country gb
sapi config set default_timeout 90

Settable keys: api_key, default_country, default_output_format, default_timeout.


Output & Piping

By default, sapi prints human-readable output to stdout and all non-data output (warnings, prompts, progress) to stderr.

When stdout is a pipe, sapi automatically switches to JSON mode:

sapi scrape https://example.com | jq .body
sapi jobs list | jq '.[].status'
sapi structured google serp "nodejs" | jq '.organic_results[0].title'

Force JSON mode explicitly with --json:

sapi account --json

Force a specific output format with --output:

sapi scrape https://example.com --output markdown

Environment Variables

| Variable | Description | | -------------------- | ------------------------------- | | SCRAPERAPI_API_KEY | API key (overrides config file) |


Requirements