Repository navigation
Quick Start
This page walks you through installing nansen-go, creating a client, and making your first API call.
You will need Go 1.18 or later and a Nansen API key. You can obtain an API key from nansen.ai.
Run the following command in your module directory:
go get github.com/tigusigalpa/nansen-goBecause the library has no external dependencies, this is all you need. There is no dependency tree to audit and nothing to vendor.
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.
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)
}
}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_moneyOnce 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 |