`ranksy` is a command-line tool for running Ranksy from your terminal, a shell script, or CI. Every command maps to an API endpoint and prints either a table or raw JSON, so it drops into bash, cron, and pipelines without any glue code.

It's a scriptable alternative to the [AI assistant (MCP)](https://docs.ranksyapp.com/hc/docs/articles/connect-ai-assistant-mcp) connection. Same data, no conversation.

This article gets you started. Every command, flag, and scope is in the [CLI reference](https://api.ranksyapp.com/cli).

## Install

On macOS or Linux, run the install script:

```bash
curl -LsSf https://ranksyapp.com/cli-installer.sh | sh
```

On Windows, download the binary from [GitHub Releases](https://github.com/ranksy/ranksy-cli/releases).

To upgrade later, run `ranksy update`. If it fails with `unrecognized subcommand 'update'`, your version is older than self-update. Run the install script again. It replaces the old binary and keeps your config file.

## Authenticate

The CLI uses the same API key as the [Developer API](https://docs.ranksyapp.com/hc/docs/articles/developer-api). Create one in **Settings** > **API Keys**, then:

```bash
ranksy login rk_live_xxx
```

For CI, set `RANKSY_API_KEY` instead. Each command needs a scope on your API key. If a command fails with `403`, the key does not have the necessary scope.

⚠️ **Warning:** Treat the key like a password. Use a key scoped to only what the script needs, and never commit it.

## First Commands

```bash
ranksy whoami  # which apps this key can reach
ranksy apps list
ranksy --app 01HZX9ABCDEF rankings get  # current keyword rankings
ranksy --app 01HZX9ABCDEF keywords list --json | jq '.data[0].organic_rank'
```

`--app` takes the app's ID from `ranksy apps list`. Add `--json` to any command for the raw API response. See [all commands](https://api.ranksyapp.com/cli/commands) for customers, trials, churn, LTV, traffic, and keyword tracking.

## Sync Your App Store Ads

`ranksy ads` copies your Shopify App Store ads data from Shopify Partners into [App Store Ads](https://docs.ranksyapp.com/hc/docs/articles/app-store-ads). Connect once, then sync every day:

```bash
ranksy ads connect   # log in to Partners, map each Shopify app to a Ranksy app
ranksy ads sync      # the last 3 complete days

# cron: every morning at 06:00
0 6 * * * ranksy ads sync -q
```

`ranksy ads` opens a real Chrome window and you log in to Partners yourself. `ranksy` never sees your Shopify password. Your API key needs the `apps:read` and `ads:write` scopes.

If your apps live in several Partners organizations, run `ranksy ads connect --org <id>` for each one. `ranksy ads sync` then syncs all of them. To backfill, add `--from 2025-01-01`.

The [ads sync reference](https://api.ranksyapp.com/cli/ads) covers organizations, date ranges, resuming an interrupted backfill, and what to do when the Partners session expires.

## CLI, API, or AI Assistant?

Three ways into the same data:

- **CLI** for scripts, cron jobs, and CI checks. One binary, no code to write.
- **Developer API** for building Ranksy data into your own app. Full request and response reference in the [API reference](https://api.ranksyapp.com).
- **AI assistant (MCP)** for asking questions in plain English and getting charts back.

## Next steps

- [CLI reference](https://api.ranksyapp.com/cli) — Every command, flag, scope, and exit code.
- [Developer API](https://docs.ranksyapp.com/hc/docs/articles/developer-api) — Create an API key with the scopes that your commands need.
- [Connect an AI Assistant (MCP)](https://docs.ranksyapp.com/hc/docs/articles/connect-ai-assistant-mcp) — Ask questions about the same data in plain language.
- [App Store Ads](https://docs.ranksyapp.com/hc/docs/articles/app-store-ads) — See the ads data that `ranksy ads sync` imports.