Skip to content
Golang API client for NS1
Go Other
  1. Go 99.2%
  2. Other 0.8%
Branch: v2
Clone or download
Pull request Compare This branch is 2 commits ahead of ns1:v2.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
git-hooks
rest
script
.gitignore
.travis.yml
LICENSE.txt
Makefile
README.md
doc.go
go.mod
go.sum

README.md

Build Status GoDoc

NS1 Golang SDK

The golang client for the NS1 API: https://ns1.com/api/

Installing

$ go get gopkg.in/ns1/ns1-go.v2

Examples

See more

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"
	"time"

	api "gopkg.in/ns1/ns1-go.v2/rest"
)

func main() {
	k := os.Getenv("NS1_APIKEY")
	if k == "" {
		fmt.Println("NS1_APIKEY environment variable is not set, giving up")
		os.Exit(1)
	}

	httpClient := &http.Client{Timeout: time.Second * 10}
	client := api.NewClient(httpClient, api.SetAPIKey(k))

	zones, _, err := client.Zones.List()
	if err != nil {
		log.Fatal(err)
	}

	for _, z := range zones {
		fmt.Println(z.Zone)
	}

}

Contributing

Contributions, ideas and criticisms are all welcome.

Run tests:

make test

Local dev: use go mod replace in client code to point to local checkout of this repository.

Consider running ./script/install-git-hooks to install local git hooks for this project.

LICENSE

Apache2 - see the included LICENSE file for more information

You can’t perform that action at this time.