Ranksy CLI

ranksy is the command-line client for this API. Each command calls one API endpoint with your API key and prints a table, or the raw JSON response with --json. Use it in shell scripts, cron jobs, and CI, and to sync your Shopify App Store ads into Ranksy.


Install

On macOS or Linux, run the install script:

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

Prebuilt binaries for Linux, macOS, and Windows are on GitHub Releases. On Windows, download the binary from there. The install script is for macOS and Linux only.

To see your version, run ranksy --version.

Update

ranksy update          # install the latest release
ranksy update --check  # only report whether a newer version exists

ranksy update works only when you installed ranksy with the install script, because it reads the install receipt that the script writes. If you downloaded the binary yourself, download the new version from GitHub Releases.

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


Authenticate

The CLI uses the same API key as the rest of this API. Create one in Ranksy under Settings > API Keys. See Getting a key.

ranksy login rk_live_xxx

ranksy login saves the key in the config file and prints the path. On macOS and Linux, only your user account can read the file.

For CI, set an environment variable instead:

export RANKSY_API_KEY=rk_live_xxx

If you set the key in more than one place, ranksy uses the first one it finds, in this order:

  1. The --api-key flag.
  2. The RANKSY_API_KEY environment variable.
  3. The config file.

At startup, ranksy also reads a .env file in the current folder, or in the nearest parent folder that has one. A RANKSY_API_KEY or RANKSY_BASE_URL in that file works as if you had exported it. A variable that is already exported in your shell wins over the .env file.

Permissions

Each command needs the permission of the endpoint that it calls, on the key and on the team member who created the key. If a command fails with 403, the key or its creator lacks that permission, and the error message names it. Create a key with the permissions your script needs.

These commands need no permission, only a valid key: whoami, apps list, listing get, reviews list, and ads connect.

The other commands that read data need these permissions. + revenue means the key also needs revenue.overview or revenue.earnings:

PermissionCommands
aso.keywordsrankings get, rankings by-keyword, keywords list, keywords trends
traffic.sourcestraffic overview, traffic source-trends
traffic.attributioninstalls get, traffic funnel, keywords installs-by-source
traffic.attribution + revenuetraffic attribution
traffic.adskeywords cannibalization, keywords ad-performance
revenue.retentionretention-cohorts
revenue.installationsuninstall-reasons, store-installs
revenue.trials + revenueactive-trials
revenue.churn + revenuechurned-customers
revenue.subscriptions + revenuelifecycle-events
revenue.ltv + revenueltv customers, ltv cohorts

Two groups of commands write data:

PermissionCommands
aso.trackedkeywords track, keywords untrack
integrations.manageads sync

login, update, and ads disconnect make no API call and need no permission. A key created before permissions also needs the scope of each command, which the Command reference lists.


Config file

ranksy login and ranksy ads connect write a TOML config file. The default paths are:

SystemConfig file
Linux~/.config/ranksy/config.toml
macOS~/Library/Application Support/com.ranksy.ranksy/config.toml
Windows%APPDATA%\ranksy\ranksy\config\config.toml

On Linux, $XDG_CONFIG_HOME moves the file. You can also edit it yourself:

config.toml

api_key = "rk_live_xxx"
app = "01HZX9ABCDEF"                      # default for --app
base_url = "https://ranksyapp.com/api/v1" # default for --base-url

[ads]                                     # written by `ranksy ads connect`
orgs = ["1234567"]
  • Name
    api_key
    Type
    string
    Description

    The API key that ranksy login saves.

  • Name
    app
    Type
    string
    Description

    The app ID that commands use when you don't pass --app.

  • Name
    base_url
    Type
    string
    Description

    The API base URL. The default is https://ranksyapp.com/api/v1. You rarely need to change it.

  • Name
    [ads]
    Type
    table
    Description

    The connected Shopify Partners organizations and the mapping of each Shopify app to a Ranksy app. ranksy ads connect and ranksy ads disconnect maintain it. See Sync App Store Ads.

ranksy keeps keys that it doesn't know when it rewrites the file.

ranksy ads also uses a data folder, for the Chrome profile that keeps your Shopify Partners login, and a cache folder, for the raw ads exports:

SystemData folder (partners-chrome)Cache folder (ads-export)
Linux~/.local/share/ranksy/~/.cache/ranksy/
macOS~/Library/Application Support/com.ranksy.ranksy/~/Library/Caches/com.ranksy.ranksy/
Windows%APPDATA%\ranksy\ranksy\data\%LOCALAPPDATA%\ranksy\ranksy\cache\

Choose an app

Most commands read the data of one app, so they need its ID. Find the IDs with ranksy apps list, then pass one with --app:

ranksy apps list
ranksy --app 01HZX9ABCDEF rankings get

To stop typing it, add app = "01HZX9ABCDEF" to the config file. --app on the command line wins over the config file. Without either, an app command fails with no app selected.

whoami, apps list, login, update, and the ads commands don't need --app.

Global options

These options work with every command, before or after the command name:

OptionWhat it does
--jsonPrints the raw API response instead of a table.
--api-key <key>Uses this key. Also read from RANKSY_API_KEY.
--base-url <url>Uses this API base URL. Also read from RANKSY_BASE_URL.
--app <id>Uses this app. Overrides app in the config file.
--watch <secs>Runs the command again every secs seconds, until you stop it.
-q, --quietPrints only the result, without progress messages.

Output

By default, ranksy prints a table with one row for each item in the response's data list, or one row for a single object. A few commands, such as apps list and rankings get, pick their columns. The others show every field that the API returned, and a nested value shows as JSON in its cell.

For anything beyond a quick look, use --json. It prints the response body as the API returns it, so the API reference describes its fields. The one exception is keywords untrack: the API answers 204 with no body, so the CLI prints a small confirmation object with the keyword and its slug.

ranksy --app 01HZX9ABCDEF keywords list --json \
  | jq '.data[0].organic_rank'

--watch 60 runs the command again every 60 seconds, which is handy for keeping a ranking check open in a terminal.

Exit codes

CodeMeaning
0Success.
1The API returned an error, or the command failed at runtime. The error message is on stderr.
2Usage error: an unknown command, a missing argument, or an invalid flag value.

CI can gate on these codes. For ranksy ads sync, see Exit codes and failures.

Retries and timeouts

If the API returns 429 or a 5xx error, ranksy sends the request again, up to 3 times, after 0.4, 0.8, and 1.6 seconds. Other errors, such as 401, 403, 404, and 422, fail at once. Requests count toward your rate limit and plan quota like any other API request.

The bulk upload of ranksy ads sync waits up to 10 minutes for each response, because the API validates a large number of rows in one request.