https://github.com/weppos/domainr-go
A Go client for the Domainr API.
https://github.com/weppos/domainr-go
Last synced: about 1 year ago
JSON representation
A Go client for the Domainr API.
- Host: GitHub
- URL: https://github.com/weppos/domainr-go
- Owner: weppos
- License: mit
- Created: 2016-02-01T16:03:56.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-03T18:27:40.000Z (almost 10 years ago)
- Last Synced: 2025-01-30T07:30:14.346Z (over 1 year ago)
- Language: Go
- Size: 18.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Domainr API client
A Go client for the [Domainr API](http://domainr.build/).
[](https://travis-ci.org/weppos/domainr-go)
[](https://godoc.org/github.com/weppos/domainr-go/domainr)
## Getting started
```shell
$ git clone git@github.com:weppos/domainr-go.git
$ cd domainr-go
```
Run the test suite.
## Testing
```shell
$ go test ./...
```
### Live Testing
```shell
$ export DOMAINR_CLIENT_ID="some-magic-client-id"
$ go test ./... -v
```
**Example output**
```shell
$ go test ./... -v
=== RUN TestNewClient
--- PASS: TestNewClient (0.00s)
=== RUN TestLivePrivateGetStatus
&{[{domainr.com com active active}] 0xc820332b40}
--- PASS: TestLivePrivateGetStatus (1.13s)
=== RUN TestLiveGetStatus
&{domainr.com com active active}
--- PASS: TestLiveGetStatus (0.24s)
PASS
ok github.com/weppos/domainr-go/domainr 1.385s
```
**Custom domain list**
```shell
$ DOMAINR_STATUS_DOMAINS=dnsimple.com,domainr.com go test ./... -v
=== RUN TestNewClient
--- PASS: TestNewClient (0.00s)
=== RUN TestLivePrivateGetStatus
&{[{dnsimple.com com active registrar registrar} {domainr.com com active active}] 0xc82041a090}
--- PASS: TestLivePrivateGetStatus (0.50s)
=== RUN TestLiveGetStatus
&{dnsimple.com com active registrar registrar}
--- PASS: TestLiveGetStatus (0.26s)
PASS
ok github.com/weppos/domainr-go/domainr 0.772s
```
## Installation
```shell
$ go get github.com/weppos/domainr-go/domainr
```
## Usage
```go
package main
import (
"fmt"
"os"
"github.com/weppos/domainr-go/domainr"
)
func main() {
clientID := "some-magic-client-id"
client := domainr.NewClient(NewDomainrAuthentication(clientID))
// Get the status of some domains
domainResponse, err := client.Status([]string{"example.com", "example.org"})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
domain := domainResponse.Domains[0]
fmt.Printf("%s: %s", domain.Name, domain.Summary)
}
```
### Authentication
This library supports both Mashape and Commercial authentication.
```go
// commercial authentication
client := domainr.NewClient(NewDomainrAuthentication("client-id"))
// mashape authentication
client := domainr.NewClient(NewMashapeAuthentication("mashape-api-key"))
```
The API endpoint is automatically adapted according to the type of authentication selected.
## License
Copyright (c) 2016 Simone Carletti. This is Free Software distributed under the MIT license.