> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hasdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Single-binary CLI for the HasData APIs — wired for shell scripts, LLM agents, and RAG pipelines.

The **HasData CLI** is a static Go binary that exposes every HasData API as a subcommand. Output is JSON on stdout — pipe it into `jq`, redirect it to a file, or call it from any language via `subprocess`. Source: [github.com/HasData/hasdata-cli](https://github.com/HasData/hasdata-cli).

## Install

<CodeGroup>
  ```bash macOS / Linux theme={null}
  curl -sSL https://raw.githubusercontent.com/HasData/hasdata-cli/main/install.sh | sh
  ```

  ```bash Go theme={null}
  go install github.com/HasData/hasdata-cli@latest
  ```

  ```bash Windows theme={null}
  # Download the .zip from the Releases page, extract, then add hasdata.exe to %PATH%.
  # https://github.com/HasData/hasdata-cli/releases
  ```
</CodeGroup>

The install script verifies SHA-256 checksums and detects OS/arch automatically.

## Authentication

Get your API key from the [dashboard](https://app.hasdata.com), then save it once:

```bash theme={null}
hasdata configure
```

This writes the key to `~/.hasdata/config.yaml`.

Resolution order, highest precedence first:

1. `--api-key <key>` flag
2. `HASDATA_API_KEY` environment variable
3. `~/.hasdata/config.yaml`

## Usage

```
hasdata <command> [flags] [--pretty|--raw] [--output FILE]
```

Each API endpoint is a subcommand. Flag names mirror the API parameters, kebab-cased: `outputFormat` → `--output-format`, `priceMin` → `--price-min`. Object/array params take a `--<flag>-json` variant that accepts a JSON string, file path, or stdin.

### Examples

```bash Google SERP theme={null}
hasdata google-serp --q "langchain vs llamaindex" --gl us --pretty
```

```bash Web Scraping with AI extraction theme={null}
hasdata web-scraping \
  --url "https://news.ycombinator.com" \
  --output-format markdown \
  --ai-extract-rules-json '{"top_story":{"type":"string"}}'
```

```bash Zillow listing search theme={null}
hasdata zillow-listing \
  --keyword "Austin, TX" --type forSale \
  --price-min 400000 --price-max 900000 \
  --beds-min 3 --sort priceLowToHigh
```

### Output and exit codes

Output auto-formats as pretty JSON when stdout is a TTY and as raw JSON when piped. Force either with `--pretty` / `--raw`. Exit codes: `0` success, `1` user error, `2` network, `3` API 4xx, `4` API 5xx.

### Common flags

| Flag                     | Purpose                                            |
| ------------------------ | -------------------------------------------------- |
| `--api-key`              | Override the configured API key                    |
| `--pretty` / `--raw`     | Force output formatting                            |
| `--output FILE`          | Write the response to a file                       |
| `--verbose`              | Print request URL and rate-limit headers to stderr |
| `--timeout`, `--retries` | Per-request controls                               |
| `--help`                 | Per-command schema and examples                    |

## Supported commands

The CLI ships a subcommand for every API documented under **Web Scraping API**, **Google SERP API**, **Google AI Mode API**, **Google Maps API**, and **Scraper APIs**. Run `hasdata --help` for the full list, or `hasdata <command> --help` for parameter schemas.

## Updates

```bash theme={null}
hasdata update --check    # check for a new version
hasdata update            # install the latest release
```

The CLI auto-checks daily and notifies via stderr; it never updates without your consent.

## Billing

Each subcommand consumes credits at the same rate as a direct API call. See [Credits and Concurrency](/credits-and-concurrency) for details.
