> For the complete documentation index, see [llms.txt](https://docs.scraperapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scraperapi.com/integrations/llm-integrations/scraperapi-cli.md).

# ScraperAPI CLI

The `scraperapi-cli` npm package exposes the **full** ScraperAPI surface as a command-line tool (sapi). Use it from the shell, in bash pipelines, cron jobs, or CI/CD workflows.

### Requirements

* Node.js 18 or higher
* ScraperAPI account and API key

### Installation

```bash
npm install -g scraperapi-cli
```

### Authentication

`sapi` looks for your API key in this order:

* `--api-key` flag
* `SCRAPERAPI_API_KEY` environment variable
* Config file written by `sapi init`

### Quick Start

```bash
# 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
```

### Commands & Flags

{% tabs %}
{% tab title="Commands" %}

<table><thead><tr><th width="212.037109375">Command</th><th>Result</th></tr></thead><tbody><tr><td><code>sapi init</code></td><td>Interactive setup. Prompts for your API Key and saves it to config.</td></tr><tr><td><code>sapi scrape &#x3C;url></code></td><td>Scrape a URL. Check the 'Flags' tab to see all supported parameters.</td></tr><tr><td><code>sapi cost &#x3C;url></code></td><td>Check credit cost without executing.</td></tr><tr><td><code>sapi jobs</code></td><td>Manage <a href="/pages/9fmHwAQhEjwwCfFUiovj">async jobs</a> (list, get, cancel, batch up to 50k URLs).</td></tr><tr><td><code>sapi structured</code></td><td>Fetch <a href="/pages/NbQNy3NIXJCvK0z3nwfy">structured data</a> from <strong>Amazon</strong>, <strong>Google</strong>, <strong>Walmart</strong>, <strong>eBay</strong> and <strong>Redfin</strong></td></tr><tr><td><code>sapi crawler</code></td><td><a href="/pages/x7ppoMyIbpskmqaByd91">Crawl</a> an entire domain and scrape all discovered URLs.</td></tr><tr><td><code>sapi pipeline</code></td><td>Manage <a href="/pages/pgX8a2glQu7Or2xGFysv">DataPipeline</a> projects.</td></tr><tr><td><code>sapi account</code></td><td>View account usage and manage API Key.</td></tr><tr><td><code>sapi config</code></td><td>Read and write config defaults without re-running <code>sapi init</code>.</td></tr></tbody></table>
{% endtab %}

{% tab title="Flags" %}

| 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                      |
| {% endtab %}       |                                                |
| {% endtabs %}      |                                                |

**For detailed information on the CLI and examples, visit the** [**scraperapi-cli npm package**](https://www.npmjs.com/package/scraperapi-cli)**.**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scraperapi.com/integrations/llm-integrations/scraperapi-cli.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
