README.md
1# INWX Go API client
2
3[![Build Status](https://travis-ci.com/nrdcg/goinwx.svg?branch=master)](https://travis-ci.com/nrdcg/goinwx)
4[![GoDoc](https://godoc.org/github.com/nrdcg/goinwx?status.svg)](https://godoc.org/github.com/nrdcg/goinwx)
5[![Go Report Card](https://goreportcard.com/badge/github.com/nrdcg/goinwx)](https://goreportcard.com/report/github.com/nrdcg/goinwx)
6
7This go library implements some parts of the official INWX XML-RPC API.
8
9## API
10
11```go
12package main
13
14import (
15 "log"
16
17 "github.com/nrdcg/goinwx"
18)
19
20func main() {
21 client := goinwx.NewClient("username", "password", &goinwx.ClientOptions{Sandbox: true})
22
23 _, err := client.Account.Login()
24 if err != nil {
25 log.Fatal(err)
26 }
27
28 defer func() {
29 if err := client.Account.Logout(); err != nil {
30 log.Printf("inwx: failed to logout: %v", err)
31 }
32 }()
33
34 var request = &goinwx.NameserverRecordRequest{
35 Domain: "domain.com",
36 Name: "foo.domain.com.",
37 Type: "TXT",
38 Content: "aaa",
39 TTL: 300,
40 }
41
42 _, err = client.Nameservers.CreateRecord(request)
43 if err != nil {
44 log.Fatal(err)
45 }
46}
47```
48
49### Using 2FA
50
51If it is desired to use 2FA without manual entering the TOTP every time,
52you must set the parameter `otp-key` to the secret that is shown during the setup of 2FA for you INWX account.
53Otherwise, you can skip `totp.GenerateCode` step and enter the verification code of the Google Authenticator app every time manually.
54
55The `otp-key` looks something like `EELTWFL55ESIHPTJAAHBCY7LXBZARUOJ`.
56
57```go
58package main
59
60import (
61 "log"
62 "time"
63
64 "github.com/nrdcg/goinwx"
65 "github.com/pquerna/otp/totp"
66)
67
68func main() {
69 client := goinwx.NewClient("username", "password", &goinwx.ClientOptions{Sandbox: true})
70
71 resp, err := client.Account.Login()
72 if err != nil {
73 log.Fatal(err)
74 }
75
76 if resp.TFA != "GOOGLE-AUTH" {
77 log.Fatal("unsupported 2 Factor Authentication")
78 }
79
80 tan, err := totp.GenerateCode("otp-key", time.Now())
81 if err != nil {
82 log.Fatal(err)
83 }
84
85 err = client.Account.Unlock(tan)
86 if err != nil {
87 log.Fatal(err)
88 }
89
90 defer func() {
91 if err := client.Account.Logout(); err != nil {
92 log.Printf("inwx: failed to logout: %v", err)
93 }
94 }()
95
96 request := &goinwx.NameserverRecordRequest{
97 Domain: "domain.com",
98 Name: "foo.domain.com.",
99 Type: "TXT",
100 Content: "aaa",
101 TTL: 300,
102 }
103
104 _, err = client.Nameservers.CreateRecord(request)
105 if err != nil {
106 log.Fatal(err)
107 }
108}
109```
110
111## Supported Features
112
113Full API documentation can be found [here](https://www.inwx.de/en/help/apidoc).
114
115The following parts are implemented:
116
117* Account
118 * Login
119 * Logout
120 * Lock
121 * Unlock (with mobile TAN)
122* Domains
123 * Check
124 * Register
125 * Delete
126 * Info
127 * GetPrices
128 * List
129 * Whois
130 * Update
131* Nameservers
132 * Check
133 * Create
134 * Info
135 * List
136 * CreateRecord
137 * UpdateRecord
138 * DeleteRecord
139 * FindRecordById
140* Contacts
141 * List
142 * Info
143 * Create
144 * Update
145 * Delete
146
147## Contributions
148
149Your contributions are very appreciated.
150