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

# CLI

> Install the Stophy CLI, run your first command with no login, then log in to page through results, save output, script it and check your usage.

The `stophy` command gets web data from your terminal, your scripts and any agent that runs shell commands.

```bash theme={null}
npm install -g @stophy/cli
stophy google search "bun runtime"
```

No account, no login. You need Node.js 20 or later.

```text theme={null}
engine: google
1. Bun — A fast all-in-one JavaScript runtime
   https://bun.com/
2. oven-sh/bun: Incredibly fast JavaScript runtime, bundler ...
   https://github.com/oven-sh/bun
```

To install without Node.js, use the standalone binary.

```bash theme={null}
# macOS and Linux
curl -fsSL https://stophy.dev/install.sh | bash

# Windows (PowerShell)
irm https://stophy.dev/install.ps1 | iex
```

## Set up your agent

```bash theme={null}
npx -y @stophy/cli init --all
```

This logs you in, adds Stophy's skills to your coding agents, and adds the Stophy MCP server.

## Log in

Without a login you can run the commands marked `free` in `stophy endpoints`. To run the rest, log in with your browser.

```bash theme={null}
stophy login --browser
```

The CLI prints a code and opens stophy.dev. Check that the page shows the same code, then approve it. On a server with no browser, open the printed link on any other device. The CLI logs in once you approve there.

To use an API key instead, pass it to `login` or set it in the environment.

```bash theme={null}
stophy login --api-key st_...
export STOPHY_API_KEY="st_..."
```

`stophy logout` logs out and revokes this computer's key.

## Make a call

Name the source, then the command.

```bash theme={null}
stophy youtube search "bun runtime"
stophy reddit subreddit rust
stophy google maps search --query dentist --location Berlin
stophy youtube transcript --videoUrl https://youtu.be/M4TufsFlv_o
```

To point at one thing, use its link or its id with the matching option, like `--videoUrl` or `--videoId`. Send one, not both.

Run `stophy <source> --help` to see what a source can do, and `stophy <source> <command> --help` for every option on one command. `stophy endpoints reddit` lists the commands for a source with their cost, and `stophy describe reddit.search` shows one command's options and an example. If a value is not one the option accepts, the CLI stops before it calls Stophy and lists the values that work.

## Read the output

Lists print one row per result with its title and link. Other results print as `name: value` lines. Add `--json` for the data as JSON, with the credits used on stderr. `--raw` prints the full response, including `requestId`.

```bash theme={null}
stophy reddit search "bun runtime" --json
```

`-o <path>` writes the output to a file.

```bash theme={null}
stophy youtube search "bun runtime" --json -o results.json
```

## Page through results

When a command has more, its output ends with a `cursor`. Pass it back with `--cursor`. This needs a login.

```bash theme={null}
stophy reddit search "bun runtime" --cursor "<cursor from the last output>"
```

Commands for sites with numbered pages take `--page`, like `stophy google search "bun runtime" --page 2`. See [Page through results](/guides/paging).

## Use it in a script

A failed call exits non-zero and writes its message to stderr. The message ends with the request id, and with `Retry after Ns.` when the API says to wait. The CLI does not retry for you.

```bash theme={null}
if ! stophy reddit search "bun runtime" --json -o out.json 2>err.txt; then
  cat err.txt
  exit 1
fi
```

## Check your usage

```bash theme={null}
stophy status
stophy usage
stophy logs --days 7
```

`status` shows your login, balance and CLI version. `usage` shows your balance and all-time usage. `logs` shows your recent requests.

## Commands

| Command | What it does |
| - | - |
| `stophy init` | Log in, install the agent skills, and add the MCP server |
| `stophy login` | Log in with your browser or an API key |
| `stophy logout` | Log out and revoke this computer's key |
| `stophy <source> <command>` | Get data, for example `stophy youtube search` |
| `stophy endpoints [word]` | List every command and its cost |
| `stophy describe <id>` | Show one command's options, cost and an example |
| `stophy status` | Show your login, balance and CLI version |
| `stophy usage` | Show your balance and all-time usage |
| `stophy logs` | Show your recent requests |
| `stophy doctor` | Check your install, login and connection |
| `stophy version` | Show the CLI version |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.