An open API service indexing awesome lists of open source software.

https://github.com/bancadati/explorerclient

Simple API client for the TF explorer
https://github.com/bancadati/explorerclient

client explorer go threefold threefoldexplorer threefoldtech

Last synced: 5 months ago
JSON representation

Simple API client for the TF explorer

Awesome Lists containing this project

README

          

# Explorer client

This repo contains a simple and limited implementation of a ThreeFold explorer client.
[https://explorer.grid.tf](https://explorer.grid.tf)

This client only implements endpoints needed for the purposes of Bancadati and is therefor very limited in functionality.

## Usage

This is an example that lists all the nodes of a certain farm in pages of 10 nodes.

```go
package main

import (
"fmt"
"log"

"github.com/bancadati/explorerclient"
)

func main() {
cl, err := explorerclient.NewClient("https://explorer.grid.tf/explorer")
if err != nil {
log.Fatal(err)
}

f := &explorerclient.NodeFilter{}
f.WithFarm(173636)

pageSize := 10
page := 1

for {
nodePager := explorerclient.NewPager(page, pageSize)
nodes, err := cl.ListNodes(f, nodePager)
if err != nil {
log.Fatal(err)
}
for _, node := range nodes {
fmt.Println(node.NodeID, node.Location)
}

if len(nodes) == pageSize {
page++
continue
}

break
}
}

```