Skip to content

apitally/cli

Repository files navigation

Apitally CLI

Tests Codecov Release npm

A command-line interface for Apitally, built for agents and humans.

Apitally is a simple API monitoring and analytics tool that makes it easy to understand API usage, monitor performance, and troubleshoot issues.

Learn more about Apitally on our 🌎 website or check out the 📚 documentation.

Highlights

  • Stream API request logs from Apitally to a local DuckDB database
  • Run arbitrary SQL queries against that database to analyze API request data
  • Bundled DuckDB, no runtime dependencies, written in Rust (it's fast)

Installation

For agents

Install the apitally-cli skill using the skills CLI:

npx skills add apitally/cli

For humans

The CLI can be used with npx, no installation required:

npx @apitally/cli <command>

If you wish to install the binary directly, use the standalone installer script:

# On macOS and Linux
curl -fsSL https://apitally.io/cli/install.sh | sh
# On Windows
powershell -ExecutionPolicy Bypass -c "irm https://apitally.io/cli/install.ps1 | iex"

You can also download the binary for your platform from the latest release on GitHub.

Authentication

To use the CLI, you need an API key. You can create one in the Apitally dashboard under Settings → API keys.

Then run the auth command to configure your API key interactively:

npx @apitally/cli auth

Or provide the key directly:

npx @apitally/cli auth --api-key "your-api-key"

The API key is saved to ~/.apitally/auth.json.

You can also set the API key via the APITALLY_API_KEY environment variable or pass the --api-key flag to any command.

Commands

Command Description
auth Configure API key
whoami Check authentication and show team info
apps List all apps in your team
consumers List consumers for an app
request-logs Fetch request log data for an app
sql Run SQL queries against a local DuckDB database

Commands that fetch data from the API output NDJSON to stdout by default. They accept a --db flag to write data to a local DuckDB database instead, which can then be queried with the sql command. The database defaults to ~/.apitally/data.duckdb if no other path is specified.

Run npx @apitally/cli --help or npx @apitally/cli <command> --help for detailed usage information.

For a full command reference, see skills/apitally-cli/references/commands.md.

Exit codes

Code Meaning
0 Success
1 General / unknown error
2 Usage error (invalid arguments, missing required flags)
3 Authentication error (missing or invalid API key)
4 Input error (invalid argument values)
5 API / network error

Getting help

If you need help please create a new discussion on GitHub or email us at [email protected]. We'll get back to you as soon as possible.