# GoAnyAPI CLI Installation Guide

The following steps are intended for AI agents. Some steps require the user to complete actions in a browser. The CLI lets agents call the GoAnyAPI REST API from a terminal. For native MCP tools, use GoAnyAPI MCP.

## Requirements

Before installation, make sure the environment has:

- Node.js 20 or later
- npm
- A [GoAnyAPI](https://goanyapi.com) account for OAuth, or a GoAnyAPI API key for automated environments

Installation, login, and command execution must all take place under the same operating system user and in the same environment where the agent runs. Windows, WSL, Docker, and remote hosts do not automatically share credentials.

## Step 1: Install

```shell
npm install --global @goanyapi/cli
goanyapi --version
```

## Step 2: Log In

The agent runs the following command, then asks the user to sign in to GoAnyAPI in the browser window that opens, select an account, and approve access.

```shell
goanyapi login
```

The CLI uses the OAuth Authorization Code flow with PKCE and automatically receives the local callback. Do not ask the user to copy an authorization code, callback URL, or token. Do not read OAuth credentials from the system credential store.

## Step 3: Verify

```shell
goanyapi auth status
goanyapi list --output json
```

`goanyapi list` retrieves the currently available APIs from the online Catalog. To view the parameters and subcommands for a command:

```shell
goanyapi describe traffic
goanyapi traffic --help
```

## Step 4: Call an API

Agents should consistently request JSON output when calling APIs:

```shell
goanyapi traffic example.com --month 3 --output json
goanyapi dr example.com --output json
goanyapi serp --q "open source" --gl us --output json
goanyapi credits-balance --data-only --output json
```

## CI/CD and Server Automation

Browserless CI/CD pipelines, cron jobs, Docker containers, and server scripts should use an API key instead of interactive OAuth login.

macOS and Linux:

```shell
export GOANYAPI_API_KEY="ga_xxx"
goanyapi traffic example.com --month 3 --output json
```

Windows PowerShell:

```powershell
$env:GOANYAPI_API_KEY = "ga_xxx"
goanyapi traffic example.com --month 3 --output json
```

Inject the API key through a secrets management service. Do not store it in a repository, a plain configuration file, or an agent conversation.

For more commands, output formats, and troubleshooting guidance, see [GoAnyAPI CLI](https://github.com/GoAnyAPI/goanyapi-cli).
