readme.md
1# Go library for accessing the deSEC API
2
3[![Build Status](https://github.com/nrdcg/desec/workflows/Main/badge.svg?branch=master)](https://github.com/nrdcg/desec/actions)
4[![PkgGoDev](https://pkg.go.dev/badge/github.com/nrdcg/desec)](https://pkg.go.dev/github.com/nrdcg/desec)
5[![Go Report Card](https://goreportcard.com/badge/github.com/nrdcg/desec)](https://goreportcard.com/report/github.com/nrdcg/desec)
6
7An deSEC API client written in Go.
8
9desec is a Go client library for accessing the deSEC API.
10
11## Examples
12
13```go
14package main
15
16import (
17 "context"
18 "fmt"
19
20 "github.com/nrdcg/desec"
21)
22
23func main() {
24 client := desec.NewClient("token")
25
26 newDomain, err := client.Domains.Create(context.Background(), "example.com")
27 if err != nil {
28 panic(err)
29 }
30
31 fmt.Println(newDomain)
32}
33```
34
35```go
36package main
37
38import (
39 "context"
40
41 "github.com/nrdcg/desec"
42)
43
44func main() {
45 client := desec.NewClient("")
46 registration := desec.Registration{
47 Email: "email@example.com",
48 Password: "secret",
49 Captcha: &desec.Captcha{
50 ID: "00010203-0405-0607-0809-0a0b0c0d0e0f",
51 Solution: "12H45",
52 },
53 }
54
55 err := client.Account.Register(context.Background(), registration)
56 if err != nil {
57 panic(err)
58 }
59}
60```
61
62```go
63package main
64
65import (
66 "context"
67 "fmt"
68
69 "github.com/nrdcg/desec"
70)
71
72func main() {
73 client := desec.NewClient("")
74
75 _, err := client.Account.Login(context.Background(), "email@example.com", "secret")
76 if err != nil {
77 panic(err)
78 }
79
80 domains, err := client.Domains.GetAll(context.Background())
81 if err != nil {
82 panic(err)
83 }
84
85 fmt.Println(domains)
86
87 err = client.Account.Logout(context.Background())
88 if err != nil {
89 panic(err)
90 }
91}
92```
93
94## API Documentation
95
96- [API docs](https://desec.readthedocs.io/en/latest/)
97- [API endpoint reference](https://desec.readthedocs.io/en/latest/endpoint-reference.html)
98