The Vainu CLI (`vainu-cli`) is a Python package that wraps the Vainu REST API. It gives you a `vainu` terminal command and an importable `vainu_cli` library, and it handles authentication, token refresh, async job polling, and streaming on your behalf.
When to use the CLI
The CLI is the right tool when you need:
Recurring or scheduled jobs, such as a nightly export into a data warehouse
Bulk exports of thousands of rows
Programmatic list management, including creating, updating, and deleting saved lists
Streaming a large result set into your own data pipeline
For one-off lookups and ad-hoc analysis, the Vainu MCP connector requires no setup and is usually faster to reach an answer. For integrations written outside Python, call the REST API directly.
Prerequisites
Python 3.11 or later. The installer installs Python for you if it is missing.
A Vainu account with API access.
Credentials for the commands you plan to run. A static API key does not cover every command — see Authentication methods below.
Access to a terminal: Terminal on macOS, a shell on Linux, or PowerShell on Windows.
Install the CLI
Run the installer for your operating system.
macOS and Linux
curl -LsSf https://raw.githubusercontent.com/vainu-app/vainu-cli/main/scripts/install.sh | sh
Windows (PowerShell)
irm https://raw.githubusercontent.com/vainu-app/vainu-cli/main/scripts/install.ps1 | iex
The installer uses uv and places the `vainu` command in `~/.local/bin` on macOS and Linux, or `%USERPROFILE%\.local\bin` on Windows.
If you manage your own Python environment, `pip install vainu-cli` works as well. Use version `0.1.1` or later.
⚠️ Warning: Your shell caches command locations for the duration of a session. Open a new terminal window after installing, or the `vainu` command will not be found.
Sign in and verify your setup
Open a new terminal window.
Run `vainu login`. A browser window opens for you to sign in to Vainu.
Run `vainu doctor`. When the install and credentials are working, the output ends with `All checks passed.`
If the browser does not open, run `vainu login --no-browser` and open the URL printed in the terminal.
Authentication methods
The CLI supports three credential types. `vainu login` stores a cached token and has the same effect as OAuth or JWT credentials.
Method | How to set it | Commands it covers |
Static API key | `export VAINU_API_KEY=your-api-key` | `companies` and `organizations` only |
OAuth client credentials | `export VAINU_CLIENT_ID=...` and `export VAINU_CLIENT_SECRET=...`, then pass `--auth-method oauth` | All commands |
JWT refresh token | `export VAINU_JWT_REFRESH_TOKEN=...`, then pass `--auth-method jwt` | All commands |
⚠️ Warning: Access is gated by capability, not only by account. A static API key reaches `companies` and `organizations` and nothing else. The `signals-news`, `signals-data-changes`, `lists`, and `enrichment-agent` commands require OAuth, JWT, or `vainu login`. With an API key alone, these commands fail with a generic authentication error rather than a message about scope.
Environment variables
Variable | Description |
`VAINU_API_KEY` | Static API key |
`VAINU_CLIENT_ID` | OAuth client ID |
`VAINU_CLIENT_SECRET` | OAuth client secret |
`VAINU_JWT_REFRESH_TOKEN` | JWT refresh token |
`VAINU_BASE_URL` | Override the API base URL |
`VAINU_TOKEN_CACHE=0` | Fetch a fresh OAuth token instead of using the cache |
`VAINU_AUTH_STORE=file` | Use the file-based token cache instead of the OS keyring |
How tokens are cached
OAuth tokens are fetched and refreshed for you. The cache lives in your operating system keyring — Keychain, Secret Service, or Credential Locker — and falls back to a `0600` file in your user config directory when no keyring backend is available.
Cache entries are keyed by base URL, client ID, and scope, so credentials for several environments coexist without conflicting. A token rejected with a `401` is discarded and the request is retried once. Repeated `401` responses point to a bad credential rather than an expired cache entry.
To clear cached tokens, run `vainu auth logout`.
Run your first command
Look up a single company by business ID:
vainu companies --query "?country=FI&business_id=FI01320292"
Browse the field catalog to find valid field paths:
vainu fields organizations --filterable --search revenue
💡 Tip: `vainu fields organizations` is the only source of truth for valid field paths. There is no static field list, and the available fields vary by country and by the entitlements on your account.
Count matches before you export, so you know how large the result set is:
vainu organizations-count --payload '{"query": {"?GTE": {"financial_data.revenue": 1000000}}, "database": "FI"}'
Export a large result set, streamed to a file as it arrives:
vainu companies-async --query "?country=FI" --format jsonl --output finnish_companies.jsonl
ℹ️ Note: The `jsonl` and `csv` formats stream by default, writing each line as it arrives. The `json` format never streams, because the document is not valid until the last byte. Combining `--stream` with `--format json` returns an error.
Run `vainu --help`, or `vainu COMMAND --help`, for the full list of commands and flags.
Data usage restrictions
⚠️ Warning: Data retrieved through the CLI carries the same restrictions as all Vainu data. Do not use it to train, fine-tune, evaluate, or improve AI or machine-learning models, and do not use it to populate vector databases or retrieval-augmented generation systems. These restrictions also cover AI-generated output derived from Vainu data.
Troubleshooting
Problem | Fix |
`'vainu' is not recognized` | Close the terminal and open a new one. If the command still fails, reinstall. |
Command not found after installing (macOS) | Add `export PATH="$HOME/.local/bin:$PATH"` to `~/.zprofile`, then open a new terminal window. |
Command not found after installing (Linux) | Add the same line to `~/.bashrc`, then open a new terminal window. |
Command not found after installing (Windows) | Close PowerShell completely and reopen it. Confirm that `%USERPROFILE%\.local\bin` exists. |
The login browser does not open | Run `vainu login --no-browser` and open the printed URL manually. |
`signals-*`, `lists`, or `enrichment-agent` commands fail with an authentication error | These commands need OAuth, JWT, or `vainu login`. An API key is not enough. |
`ModuleNotFoundError: No module named 'vainu_cli.cli'` | An older, broken install is earlier in your `PATH`. Run `which -a vainu` to find duplicates, remove the stale one or run `vainu update`, then open a new terminal window. |
You need the latest version | Run `vainu update`. |
Where to go next
Run `vainu --help` to see every available command.
The example payloads in the vainu-cli repository are complete request bodies for the organizations, signals, and enrichment agent endpoints. Pass any of them straight to `--payload`.
To script against Vainu in Python rather than the terminal, import the `vainu_cli` library and use the `VainuAPIKeySyncClient` or `VainuOAuthSyncClient` classes.
🧑💻 Contact Vainu Support if you have any questions! You can send an email to support@vainu.io or send a message through chat.
