> 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="/asynchronous-api/overview.md">async jobs</a> (list, get, cancel, batch up to 50k URLs).</td></tr><tr><td><code>sapi structured</code></td><td>Fetch <a href="/structured-data-endpoints/overview.md">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="/scraperapi-crawler-v2.0/introduction.md">Crawl</a> an entire domain and scrape all discovered URLs.</td></tr><tr><td><code>sapi pipeline</code></td><td>Manage <a href="/data-pipeline/what-is-datapipeline.md">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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
