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
- Host: GitHub
- URL: https://github.com/bancadati/explorerclient
- Owner: Bancadati
- License: mit
- Created: 2020-05-14T18:32:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-15T13:34:26.000Z (over 5 years ago)
- Last Synced: 2025-10-01T05:29:28.682Z (8 months ago)
- Topics: client, explorer, go, threefold, threefoldexplorer, threefoldtech
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
}
}
```