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

# CLI Overview

> Command-line interface for ScrapeBadger — Twitter, Google, Vinted, and Web Scraping from the terminal.

# ScrapeBadger CLI

A command-line tool for accessing ScrapeBadger APIs directly from your terminal. Supports multiple output formats, pipe-friendly design, and field selection.

## Install

<CodeGroup>
  ```bash pip theme={null}
  pip install scrapebadger-cli
  ```

  ```bash uv theme={null}
  uv tool install scrapebadger-cli
  ```
</CodeGroup>

## Quick Start

```bash theme={null}
# Set up your API key
scrapebadger auth --api-key sb_live_...

# Get a Twitter user profile
scrapebadger twitter user elonmusk

# Search tweets as a table
scrapebadger twitter search "AI agents" --output table

# Google web search
scrapebadger google search "python 3.13" --gl us --num 20

# Google shopping + per-product merchant URL enrichment
scrapebadger google shopping "laptop" --max-price 2000
scrapebadger google shopping-click "Lenovo IdeaPad 5" --source "Walmart"

# Search Vinted in Germany
scrapebadger vinted search "nike shoes" --market de

# Scrape a URL with JS rendering
scrapebadger web scrape https://example.com --js

# Check your credits
scrapebadger credits
```

## Authentication

The CLI resolves your API key in this order:

1. `SCRAPEBADGER_API_KEY` environment variable
2. `.env` file in the current directory
3. `~/.config/scrapebadger/config.json` (saved via `scrapebadger auth`)

## Output Formats

Every command supports `--output` (`-o`) to choose the format:

| Format   | Flag                | Best For                         |
| -------- | ------------------- | -------------------------------- |
| JSON     | `-o json` (default) | Piping to `jq`, programmatic use |
| CSV      | `-o csv`            | Spreadsheets, data analysis      |
| Table    | `-o table`          | Human-readable terminal output   |
| Markdown | `-o markdown`       | Documentation, reports           |

### Field Selection

Use `--fields` (`-f`) to include only specific columns:

```bash theme={null}
scrapebadger twitter trends -o csv -f name,domain_context
```

## Commands

| Group       | Commands                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Account** | `auth`, `credits`, `logout`                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **Twitter** | `user`, `tweets`, `tweet`, `search`, `followers`, `following`, `mentions`, `trends`, `replies`, `quotes`, `retweeters`, `community`, `list`, `space` + more                                                                                                                                                                                                                                                                                     |
| **Google**  | `search`, `maps-search`, `maps-place`, `maps-reviews`, `maps-photos`, `maps-posts`, `news`, `news-topics`, `news-trending`, `hotels`, `hotels-details`, `trends`, `trends-regions`, `trends-related`, `trends-trending`, `jobs`, `shopping`, `shopping-product`, `shopping-click`, `patents`, `patent`, `scholar`, `autocomplete`, `images`, `videos`, `finance`, `ai-mode`, `lens`, `product-detail` (29 commands covering 16 Google products) |
| **Vinted**  | `search`, `item`, `user`, `user-items`, `brands`, `markets`                                                                                                                                                                                                                                                                                                                                                                                     |
| **Web**     | `scrape`, `detect`, `screenshot`, `extract`, `batch`, `batch-status`                                                                                                                                                                                                                                                                                                                                                                            |

## Pipeline Examples

```bash theme={null}
# Export trending topics to CSV
scrapebadger twitter trends -o csv > trends.csv

# Get followers and pipe to jq
scrapebadger twitter followers elonmusk | jq '.[].username'

# Scrape a page and extract text
scrapebadger web scrape https://example.com --format markdown
```

## Environment Variables

| Variable               | Description                                                     |
| ---------------------- | --------------------------------------------------------------- |
| `SCRAPEBADGER_API_KEY` | Your API key                                                    |
| `SCRAPEBADGER_API_URL` | Override the API base URL (default: `https://scrapebadger.com`) |
