https://github.com/hibare/headscale-client-go
A client implementation for the Headscale HTTP API
https://github.com/hibare/headscale-client-go
client golang headscale
Last synced: 8 months ago
JSON representation
A client implementation for the Headscale HTTP API
- Host: GitHub
- URL: https://github.com/hibare/headscale-client-go
- Owner: hibare
- License: mit
- Created: 2024-11-04T18:24:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-04T13:20:37.000Z (over 1 year ago)
- Last Synced: 2025-02-04T14:27:06.462Z (over 1 year ago)
- Topics: client, golang, headscale
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Headscale Client Go
[](https://pkg.go.dev/github.com/hibare/headscale-client-go)
[](https://goreportcard.com/report/github.com/hibare/headscale-client-go)
A client implementation for the [Headscale](https://headscale.net) HTTP API.
## Example (Using API Key)
```go
package main
import (
"context"
"fmt"
"log/slog"
"os"
hsClient "github.com/hibare/headscale-client-go"
)
func main() {
slog.SetLogLoggerLevel(slog.LevelDebug) // Optional
serverUrl := os.Getenv("HS_SERVER_URL")
apiToken := os.Getenv("HS_API_TOKEN")
client, err := hsClient.NewClient(serverUrl, apiToken, hsClient.HeadscaleClientOptions{})
if err != nil {
panic(err)
}
nodes, err := client.Nodes().List(context.Background())
if err != nil {
panic(err)
}
for _, node := range nodes.Nodes {
fmt.Printf("Node: %s\n", node.Name)
}
}
```