Skip to content

Latest commit

 

History

History
140 lines (103 loc) · 6.08 KB

File metadata and controls

140 lines (103 loc) · 6.08 KB
title CLI
description Install the official AnyAPI CLI, manage auth, discover APIs, and run SKUs from your terminal.

The official AnyAPI CLI is the npm package anyapi-cli with the anyapi binary.

Install

npx -y anyapi-cli@latest init

anyapi init installs the agent skills into detected agents, offers MCP registration, and mints a free trial key if none is stored. For a global binary:

npm i -g anyapi-cli
anyapi init

Repo: github.com/getanyapi-com/cli

Commands

Command What it does
anyapi signup [--label <label>] [--show-key] Mints a free trial key, saves it locally, and prints trial guidance. The secret is hidden unless you pass --show-key.
anyapi connect Starts an OAuth flow to connect a wallet and upgrade past the trial (anyapi-cli >= 0.3.0).
anyapi login Signs in to an AnyAPI account with the cross-device OAuth device flow. It does not bind a localhost callback.
anyapi login --api-key aa_live_... Stores an existing dashboard key locally without starting OAuth.
anyapi search [query] [--category <category>] [--platform <platform>] Searches the public catalog and prints matching SKUs, names, and USD price terms. The query is optional when you pass --category or --platform (anyapi-cli >= 0.9.0).
anyapi list [--category <category>] Lists catalog APIs, optionally filtered by category.
anyapi describe <sku> Prints the authenticated API definition, including schemas and USD pricing.
anyapi run <sku> --input '<json>' [-i file] [--no-wait] [--fields a,b] [--max-items N] [--summary] [-o path] [--json] Runs an API with JSON input and waits for durable completion by default.
anyapi requests get <request-id> Gets the current state of a durable Request.
anyapi requests wait <request-id> Waits for a durable Request and prints its result.
anyapi balance Prints the remaining USD balance for the active key.
anyapi report-bug <summary> [--details <text>] [--sku <sku>] [--request-id <id>] [--contact <email>] Reports something broken: a wrong or empty result, a misleading error, a price that looks off. Free, never charged (anyapi-cli >= 0.8.0).
anyapi feedback <summary> [--details <text>] [--sku <sku>] [--request-id <id>] [--contact <email>] Sends feedback that is not a defect: a missing API, a missing field, confusing docs. Free, never charged (anyapi-cli >= 0.8.0).
anyapi init [--all] [--yes] Installs bundled agent skills, shows or applies MCP setup snippets, and mints a free trial key if none is stored.
anyapi setup skills Installs only the bundled skills.

anyapi search takes any non-empty combination of a query, --category, and --platform; ranking falls back from semantic to keyword. anyapi list only browses, with an optional category. Both print the USD offer from discovery.

pricing.from is either a flat offer (model, unit: "request", maxUsd, maxPer1kUsd) or a linear offer (model, unit, baseUsd, perUnitUsd, maxUsd, maxPer1kUsd). pricing.failoverMaxUsd and pricing.failoverMaxPer1kUsd are the greatest fallback ceiling, and failover reports whether AnyAPI currently has an alternate route. The CLI shows these as the gateway publishes them and never derives one from another. Run anyapi describe <sku> to see the complete offer, and see Pricing for what each field means.

Authentication

The CLI resolves auth in this order:

  1. --api-key flag
  2. ANYAPI_API_KEY environment variable
  3. ~/.anyapi/config.json
  4. Interactive self-signup for commands that require auth

Application code should read ANYAPI_API_KEY, not ~/.anyapi/config.json.

Sign in to an account

anyapi login

The CLI prints a verification URL and user code and opens the URL when it can. Approve from any browser or device. The CLI saves the access token, refresh token, expiry, and scope to ~/.anyapi/config.json and refreshes the token before it expires. This is separate from anyapi connect, which upgrades a saved free trial and preserves its trial receipt.

To store an existing dashboard key without OAuth:

anyapi login --api-key aa_live_...

Self-signup

anyapi signup calls the endpoint described in Let your agent onboard itself:

npx -y anyapi-cli@latest signup --label my-agent

The key is stored in ~/.anyapi/config.json. The trial key carries a budget of about $0.05, creates no account, and self-expires in 7 days.

Run output

By default, anyapi run writes JSON to:

.anyapi/<sku>-<timestamp>.json

The command prints the output path, costUsd, and item count. Use --json to print the response to stdout, or -o path to choose the file. The CLI does not rewrite output.

For a long-running API, the CLI polls the Request until it finishes. Pass --no-wait to return its Request ID immediately. If you press Ctrl-C after acceptance, the CLI prints the anyapi requests wait <request-id> command to resume. Each CLI invocation uses a fresh random idempotency key.

Context-budget flags

Use these flags when a result is too large for an agent's context window:

Flag Effect
--fields a,b Keeps only selected keys on each result item.
--max-items N Caps returned rows.
--summary Returns a structural outline instead of the bulk data.

They trim only what is returned. costUsd still reflects the full result the API produced.

402 and upgrading past the trial

When the trial budget is spent, a run returns 402 trial_cap_reached. To keep going, connect a wallet (anyapi-cli >= 0.3.0):

anyapi connect

This starts an OAuth flow with a localhost callback and prints one consent URL. A human opens it, signs in at the dashboard, sets a spend limit, and approves. The agent then keeps working on the same session.

A human with a funded account can instead create a non-expiring key at the dashboard and store it with anyapi login --api-key aa_live_....