Skip to content

Quick Start

Igor Sazonov edited this page Jul 14, 2026 · 1 revision

This page walks you through installing nansen-go, creating a client, and making your first API call.

Prerequisites

You will need Go 1.18 or later and a Nansen API key. You can obtain an API key from nansen.ai.

Installation

Run the following command in your module directory:

go get github.com/tigusigalpa/nansen-go

Because the library has no external dependencies, this is all you need. There is no dependency tree to audit and nothing to vendor.

Creating a Client

Import the package and call nansen.New with your API key. All configuration options are optional; sensible defaults are applied for anything you omit.

import "github.com/tigusigalpa/nansen-go"

client, err := nansen.New(os.Getenv("NANSEN_API_KEY"),
    nansen.WithTimeout(30*time.Second),
    nansen.WithRetry(3, 500*time.Millisecond, 5*time.Second),
)
if err != nil {
    log.Fatal(err)
}

nansen.New returns an error if the API key is empty or if any option is invalid (for example, a non-positive timeout). See Configuration for the full list of options.

Making an API Call

Every service method accepts a context.Context as its first argument. Use context.WithTimeout or context.WithDeadline to control the maximum time you are willing to wait for a response.

package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "time"

    "github.com/tigusigalpa/nansen-go"
)

func main() {
    client, err := nansen.New(os.Getenv("NANSEN_API_KEY"),
        nansen.WithTimeout(30*time.Second),
        nansen.WithRetry(3, 500*time.Millisecond, 5*time.Second),
    )
    if err != nil {
        log.Fatal(err)
    }

    ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
    defer cancel()

    tf := nansen.Timeframe24H
    resp, err := client.TokenGodMode.TokenScreener(ctx, &nansen.TokenScreenerRequest{
        Chains:    []nansen.Chain{nansen.ChainEthereum, nansen.ChainSolana},
        Timeframe: &tf,
        Pagination: &nansen.PaginationRequest{
            Page:    nansen.IntPtr(1),
            PerPage: nansen.IntPtr(20),
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, t := range resp.Data {
        fmt.Printf("%s on %s\n", t.TokenSymbol, t.Chain)
    }
}

Running the Bundled Examples

The repository ships with three complete example programs in the examples/ directory. Point any of them at your API key and run:

NANSEN_API_KEY=your_api_key go run ./examples/screener
NANSEN_API_KEY=your_api_key go run ./examples/profiler
NANSEN_API_KEY=your_api_key go run ./examples/smart_money

Next Steps

Once you have the basics working, explore the individual service pages:

Service What it does
Smart Money Netflows, holdings, and DEX trades
Token God Mode Token screener, flow intelligence, who-bought-sold
Profiler Wallet balances and DEX trade history
Portfolio DeFi holdings
Historical Point-in-time backtesting data

Clone this wiki locally