https://github.com/daloman/regru-api-go
regru-api-go module for Reg.ru API v2
https://github.com/daloman/regru-api-go
golang-package regru-api
Last synced: 5 months ago
JSON representation
regru-api-go module for Reg.ru API v2
- Host: GitHub
- URL: https://github.com/daloman/regru-api-go
- Owner: daloman
- License: mit
- Created: 2022-10-19T20:13:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-03T14:42:48.000Z (over 3 years ago)
- Last Synced: 2024-06-21T09:38:05.392Z (almost 2 years ago)
- Topics: golang-package, regru-api
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# regru-api-go module for Reg.ru API v2
https://www.reg.ru provide API access to control users, billing, domains etc.
Currently only several zone (domain) control functions implemented in this module.
```bash
"zone/get_resource_records"
"zone/add_txt"
"zone/remove_record"
```
API documentation https://www.reg.ru/reseller/api2doc#common
# Access from known IP-address only
Access configuration https://www.reg.ru/user/account/#/settings/api/
```json
{
"charset" : "utf-8",
"error_code" : "ACCESS_DENIED_FROM_IP",
"error_params" : {
"command_name" : "zone/get_resource_records"
},
"error_text" : "Access to API from this IP denied",
"messagestore" : null,
"result" : "error"
}
```
## Examples
```go
// Get domain information
package main
import (
"os"
"github.com/daloman/regru-api-go/zonecontrol"
)
var username, password, domainName string
func main() {
username = os.Getenv("API_USERNAME")
password = os.Getenv("API_PASSWORD")
domainName = "mydomain.com"
zonecontrol.GetZones(username, password, domainName)
// Create TXT resource record
//zonecontrol.AddTxtRr(username, password, domainName, "_acme_foo_bar", "txt-record-content")
// Remove TXT resource record
//zonecontrol.RmTxtRr(username, password, domainName, "_acme_example", "TXT", "")
}
```
# Known Issues
Test API returns some fields as strings for test access and as int for real data, and vice versa.
Response for real account:
```json
{
"answer" : {
"domains" : [
{
"dname" : "example.xyz",
"result" : "success",
"rrs" : [
{
"content" : "111.222.111.222",
"prio" : 0,
"rectype" : "A",
"state" : "A",
"subname" : "@"
},
],
"service_id" : "12345678",
"servtype" : "domain",
"soa" : {
"minimum_ttl" : "10m",
"ttl" : "10m"
}
}
]
},
"charset" : "utf-8",
"messagestore" : null,
"result" : "success"
}
```
Response for test account:
```json
{
"answer" : {
"domains" : [
{
"dname" : "example.com",
"result" : "success",
"rrs" : [
{
"content" : "111.222.111.222",
"prio" : "0",
"rectype" : "A",
"state" : "A",
"subname" : "www"
}
],
"service_id" : 12345,
"servtype" : "domain",
"soa" : {
"minimum_ttl" : "12h",
"ttl" : "1d"
}
}
]
},
"charset" : "utf-8",
"messagestore" : null,
"result" : "success"
}
```
```json
WARN[0000] Could not unmarshal json: json: cannot unmarshal string into Go struct field rrsData.answer.Domains.Rrs.Prio of type int
INFO[0000] The answer is: {Answer:{Domains:[{Dname:mydomain.pro ErrorCode: ErrorText: ErrorParams:map[] Result:success Rrs:[{Content:111.222.111.222 Prio:0 Rectype:A State:A Subname:www}] ServiceId: Servtype:domain Soa:map[minimum_ttl:12h ttl:1d]}]} Charset:utf-8 Messagestore: Result:success ErrorCode: ErrorText: ErrorParams:map[]}
```