VPS.org API

Dogfennaeth API REST

API Rheoli DNS

Rheoli parthau a chofnodion DNS yn rhaglennol ar gyfer eich parthau.

Pwyntiau terfyn 4 pwynt terfyn
Llwybr Sylfaen /api/v1/dns-zones
Dilysu Angen Tocyn Porthwr

Trosolwg

Mae'r API DNS yn darparu rheoli llawn o ardaloedd a chofnodion DNS. Mae pob ardal yn cael ei gweinyddu ar weinyddwyr enw awdurdodol VPS.org gyda chreu a gosod ffeil ardal BIND9 yn awtomatig.

Gweinydd Enw

Nodweddion Allweddol

Dilysu

Mae angen dilysiant tocyn barwr ar bob cais API DNS. Creu tocynnau API o'ch panel rheoli cyfrif ar /account/developers/ gyda' r caniatadau canlynol:

Enghraifft

Authorization: Bearer vps_abc123def456...
Pwysig: Ni ddangosir tocynnau API ond unwaith yn ystod y creu. Cadw nhw'n ddiogel. Os ydych chi'n colli tocyn, rhaid creu un newydd.
CAEL /api/v1/dns-zones/

Rhestru Pob Parth DNS

Nôl rhestr o bob ardal DNS sydd yn eiddo i'r defnyddiwr dilysedig. Cynhelir hidlo yn ôl enw parth.

Paramedrau'r Ymholiad

Paramedrau Math Angenrheidiol Disgrifiad
domain string & # 160; Na Filter zones by exact domain name (e.g., example.com)

Cais Enghraifft

cURL
Python
JavaScript
curl -X GET "https://admin.vps.org/api/v1/dns-zones/" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
import requests

url = "https://admin.vps.org/api/v1/dns-zones/"
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}

response = requests.get(url, headers=headers)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/dns-zones/', {
  headers: {'Authorization': 'Bearer YOUR_API_TOKEN'}
});

const zones = await response.json();
console.log(zones);

Ymateb Enghraifft

[
  {
    "uuid": "abc123-def456-ghi789",
    "domain": "example.com",
    "created_at": "2024-01-15T10:30:00Z",
    "record_count": 12
  },
  {
    "uuid": "xyz789-uvw456-rst123",
    "domain": "myapp.io",
    "created_at": "2024-06-20T14:15:00Z",
    "record_count": 8
  }
]

Meysydd Ymateb

Maes Math Disgrifiad
uuid string Unique zone identifier (used in API requests)
domain string Domain name for this DNS zone
created_at datetime Zone creation timestamp (ISO 8601 format)
record_count integer Total number of DNS records in this zone

Codau Statws Ymateb

200 Successfully retrieved DNS zones list
401 Unauthorized - Invalid or missing API token
403 Forbidden - Token lacks dns:list permission
CAEL /api/v1/dns-zones/{uuid}/

Nôl Manylion Cylchfa DNS

Nôl gwybodaeth fanylach am ardal DNS benodol, gan gynnwys pob cofnod.

Paramedrau Llwybr

Paramedrau Math Angenrheidiol Disgrifiad
uuid string Ie Unique zone identifier

Ymateb Enghraifft

{
  "uuid": "abc123-def456-ghi789",
  "domain": "example.com",
  "created_at": "2024-01-15T10:30:00Z",
  "record_count": 5,
  "records": [
    {
      "uuid": "rec-001",
      "record_type": "A",
      "name": "@",
      "value": "192.0.2.1",
      "ttl": 3600,
      "priority": null,
      "created_at": "2024-01-15T10:30:00Z"
    },
    {
      "uuid": "rec-002",
      "record_type": "MX",
      "name": "@",
      "value": "mail.example.com",
      "ttl": 3600,
      "priority": 10,
      "created_at": "2024-01-15T10:32:00Z"
    }
  ]
}

Codau Statws Ymateb

200 Successfully retrieved zone details
404 Zone not found or not owned by user
POST /api/v1/dns-zones/

Creu Cylchfa DNS

Creu cylchfa DNS newydd ar gyfer parth. Bydd y gymuned yn cael ei chyflwyno ar unwaith i VPS.org o weinyddwyr enw.

Paramedrau Corff y Cais

Paramedrau Math Angenrheidiol Disgrifiad
domain string Ie Domain name (e.g., example.com)

Cais Enghraifft

cURL
Python
JavaScript
curl -X POST "https://admin.vps.org/api/v1/dns-zones/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "newdomain.com"}'
import requests

url = "https://admin.vps.org/api/v1/dns-zones/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {"domain": "newdomain.com"}

response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/dns-zones/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({domain: 'newdomain.com'})
});

const zone = await response.json();
console.log(zone);

Ymateb Enghraifft

{
  "uuid": "new-zone-uuid",
  "domain": "newdomain.com",
  "created_at": "2026-01-18T16:45:00Z",
  "record_count": 0,
  "records": []
}

Codau Statws Ymateb

201 DNS zone created successfully
400 Bad Request - Invalid domain name or zone already exists
403 Forbidden - Token lacks dns:create permission
DILEU /api/v1/dns-zones/{uuid}/

Dileu Cylchfa DNS

Dileu cylchfa DNS a' r holl gofnodion cysylltiedig yn barhaol. Ni ellir dadwneud y weithred yma.

Paramedrau Llwybr

Paramedrau Math Angenrheidiol Disgrifiad
uuid string Ie Unique zone identifier

Codau Statws Ymateb

204 Zone deleted successfully (no response body)
403 Forbidden - Token lacks dns:delete permission
404 Zone not found
CAEL /api/v1/dns-zones/{uuid}/records/

Rhestr o gofnodion DNS yn y Cylchfa

Nôl pob cofnod DNS ar gyfer ardal benodol (llwybr neilltuedig).

Paramedrau Llwybr

Paramedrau Math Angenrheidiol Disgrifiad
uuid string Ie Zone UUID

Cais Enghraifft

curl -X GET "https://admin.vps.org/api/v1/dns-zones/{uuid}/records/" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Ymateb Enghraifft

[
  {
    "uuid": "rec-001",
    "record_type": "A",
    "name": "@",
    "value": "192.0.2.1",
    "ttl": 3600,
    "priority": null,
    "created_at": "2024-01-15T10:30:00Z"
  },
  {
    "uuid": "rec-002",
    "record_type": "MX",
    "name": "@",
    "value": "mail.example.com",
    "ttl": 3600,
    "priority": 10,
    "created_at": "2024-01-15T10:32:00Z"
  }
]
POST /api/v1/dns-zones/{uuid}/records/

Creu Cofnod DNS yn y Cylchfa

Ychwanegu cofnod DNS newydd i ardal benodol (llwybr neilltuedig).

Paramedrau Corff y Cais

Paramedrau Math Angenrheidiol Disgrifiad
record_type string Ie Record type: A, AAAA, CNAME, MX, TXT, NS, SRV, CAA
name string Ie Record name (@ for root, subdomain, or FQDN)
value string Ie Record value (IP address, hostname, text)
ttl integer No Time to live in seconds (default: 3600)
priority integer For MX/SRV Priority (required for MX and SRV records)

Cais Enghraifft

cURL
Python
curl -X POST "https://admin.vps.org/api/v1/dns-zones/{uuid}/records/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "record_type": "A",
    "name": "www",
    "value": "192.0.2.1",
    "ttl": 3600
  }'
import requests

url = f"https://admin.vps.org/api/v1/dns-zones/{zone_uuid}/records/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "record_type": "A",
    "name": "www",
    "value": "192.0.2.1",
    "ttl": 3600
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

Codau Statws Ymateb

201 DNS record created successfully
400 Bad Request - Invalid parameters or validation error (e.g., MX record missing priority)
GET PUT PATCH DELETE /api/v1/dns-records/{uuid}/

Rheoli Cofnodion DNS (Cyrchfan Uniongyrchol)

Gweithrediadau CRUD llawn ar gofnodion DNS unigol gan ddefnyddio UUID cofnod.

Gweithrediadau ar Gael

Paramedrau Ymholiad (ar gyfer GET /api/v1/dns-records/)

Parameter Math Disgrifiad
zone string Filter records by zone UUID
record_type string Filter by record type (A, AAAA, MX, etc.)

Diweddaru TTL Cofnod

curl -X PATCH "https://admin.vps.org/api/v1/dns-records/{rec-uuid}/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ttl": 1800}'

Supported DNS Record Types

Math Purpose Example Value Priority Required
A Maps domain to IPv4 address 192.0.2.1 & # 160; Na
AAAA Maps domain to IPv6 address 2001:0db8::1 & # 160; Na
CNAME Creates alias to another domain example.com & # 160; Na
MX Mail server for domain mail.example.com Ie
TXT Text record (SPF, DKIM, verification) v=spf1 include:_spf.google.com ~all & # 160; Na
NS Nameserver delegation ns1.example.com & # 160; Na
SRV Service location record 10 5060 sip.example.com Ie
CAA Certificate authority authorization 0 issue "letsencrypt.org" & # 160; Na

Ymarfer Gorau

Ffurfweddiad TTL

Patrymau Cyffredin

Diogelwch

Triniaeth Gwallau

Gwall Cyffredin

Cod Statws Gwall & Gwaredu Iaith
400 Enw parth annilys Sicrhau bod y parth yn dilyn y rheolau enwi DNS
400 Mae angen blaenoriaeth ar y cofnod MX Cynnwys priority maes ar gyfer cofnodion MX a SRV
401 Tocyn API annilys Fformat tocyn gwirio (rhaid dechrau gyda vps_)
403 Caniatâd ar goll Creu tocyn newydd gyda gofyniad dns:* Permissions
404 Cofnod heb ei ganfod Gwirio UUID a sicrhau bod yr adnodd yn perthyn i'ch cyfrif

Ymateb Gwall Enghreifftiol

{
  "detail": "MX records require a priority value",
  "error_code": "validation_error",
  "field": "priority"
}

Newidiadau DNS

Gwirio Lledaeniad Cofnod

# Query A record
dig example.com A

# Query specific nameserver
dig @ns1.vps.org example.com

# Query MX records
dig example.com MX

# Check all records
dig example.com ANY

Defnyddio Offer Ar-lein