# Glassnode CLI

The [Glassnode CLI](https://github.com/glassnode/glassnode-cli) (`gn`) is a command-line interface for the Glassnode API. Use it to list assets and metrics, fetch data, and integrate with scripts or AI assistants via the optional skill.

## Installation

### Install script (recommended)

**Linux / macOS**

```bash
curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bash
```

This installs the latest release to `/usr/local/bin` (uses `sudo` if needed). To install to a custom directory:

```bash
INSTALL_DIR=~/bin curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bash
```

**Windows (PowerShell)**

```powershell
irm https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.ps1 | iex
```

This installs to `%LOCALAPPDATA%\glassnode\bin` and adds it to your user `PATH` if needed.

### Manual download

Download the archive for your OS and architecture from [Releases](https://github.com/glassnode/glassnode-cli/releases), extract it, then move the binary into your `PATH` and make it executable (`chmod +x gn` on Unix).

### From source

```bash
go install github.com/glassnode/glassnode-cli@latest
```

The binary from `go install` is named `glassnode-cli`. To get the `gn` command, build with:

```bash
go build -o gn .
```

and put `gn` in your `PATH`.

## Authentication

Set your API key so the CLI can access the Glassnode API. The CLI resolves the key in this order:

1. `--api-key` flag (highest priority)
2. `GLASSNODE_API_KEY` environment variable
3. `~/.gn/config.yaml` configuration file

To persist the key in the config file:

```bash
gn config set api-key=your-key
```

See [API Key](/basic-api/api-key.md) for how to get your API key. API usage consumes [API credits](/basic-api/api-credits.md) as with direct API calls.

## Quick start

```bash
# List available assets
gn asset list

# Fetch Bitcoin's closing price for the last 30 days
gn metric get market/price_usd_close --asset BTC --since 30d
```

## Add the CLI skill (AI assistants)

To let AI coding assistants (e.g. Cursor, Codex) use the Glassnode CLI and API knowledge, add the official skill:

```bash
npx skills add glassnode/glassnode-cli
```

After adding the skill, the assistant can run `gn` commands, discover metrics and assets, and follow CLI best practices when helping you work with Glassnode data.

For full usage, examples, and bulk metrics, see the [Glassnode CLI repository](https://github.com/glassnode/glassnode-cli).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glassnode.com/basic-api/glassnode-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
