跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
其他技能

dns

Hostinger DNS API for zone record management, snapshots, and validation. Use when creating, updating, or deleting DNS records, restoring DNS snapshots, validating zone changes, or resetting DNS to defaults.

hostinger · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add hostinger/hostinger-agent-skills --skill dns

技能说明


name: dns description: Hostinger DNS API for zone record management, snapshots, and validation. Use when creating, updating, or deleting DNS records, restoring DNS snapshots, validating zone changes, or resetting DNS to defaults. last_updated: "2026-03-20" doc_source: https://developers.hostinger.com

Hostinger DNS

The DNS API enables full management of DNS zone records for domains hosted on Hostinger. You can create, update, delete, validate, and reset DNS records, as well as manage DNS snapshots for backup and restore operations.

Table of Contents

Core Concepts

DNS Records

Standard DNS record types are supported:

TypePurposeExample
AIPv4 address192.168.1.1
AAAAIPv6 address2001:db8::1
CNAMECanonical name aliaswww.example.com.
ALIASANAME/ALIAS recordexample.com.
MXMail exchangemail.example.com.
TXTText recordv=spf1 include:...
NSName serverns1.example.com.
SOAStart of authorityZone authority info
SRVService locator_sip._tcp.example.com.
CAACertificate authority auth0 issue "letsencrypt.org"

Zone Updates

When updating DNS records, the overwrite flag controls behavior:

  • overwrite: true (default) — Replaces existing records matching name and type with the new records
  • overwrite: false — Updates TTL on existing records, appends new records; if no match found, creates them

Snapshots

DNS snapshots capture the state of a domain's DNS zone at a point in time. Use them to restore previous configurations if something goes wrong.

TTL (Time-To-Live)

TTL controls how long DNS resolvers cache a record. Default is 14400 seconds (4 hours). Lower values propagate changes faster but increase DNS query load.

Common Patterns

Get DNS Records for a Domain

curl -X GET "https://developers.hostinger.com/api/dns/v1/zones/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN"

Python SDK:

from hostinger_api import Hostinger

client = Hostinger(api_token="YOUR_API_TOKEN")
records = client.dns.zone.get_dns_records("example.com")
for record in records:
    print(f"{record.type} {record.name} -> {record.content}")

TypeScript SDK:

import { Hostinger } from "hostinger-api-sdk";

const client = new Hostinger({ apiToken: "YOUR_API_TOKEN" });

const records = await client.dns.zone.getRecords("example.com");
for (const record of records) {
  console.log(`${record.type} ${record.name} -> ${record.content}`);
}

PHP SDK:

use Hostinger\Api\HostingerApi;

$client = new HostingerApi('YOUR_API_TOKEN');

$records = $client->dns->zone->getRecords('example.com');
foreach ($records as $record) {
    echo "{$record->type} {$record->name} -> {$record->content}\n";
}

Create/Update DNS Records

# Add an A record for www subdomain
curl -X PUT "https://developers.hostinger.com/api/dns/v1/zones/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "overwrite": true,
    "zone": [
      {
        "name": "www",
        "type": "A",
        "ttl": 14400,
        "records": [
          { "content": "192.168.1.1" }
        ]
      }
    ]
  }'

# Add MX records for email
curl -X PUT "https://developers.hostinger.com/api/dns/v1/zones/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "overwrite": true,
    "zone": [
      {
        "name": "@",
        "type": "MX",
        "ttl": 14400,
        "records": [
          { "content": "10 mail1.example.com." },
          { "content": "20 mail2.example.com." }
        ]
      }
    ]
  }'

# Add a TXT record for SPF
curl -X PUT "https://developers.hostinger.com/api/dns/v1/zones/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "overwrite": false,
    "zone": [
      {
        "name": "@",
        "type": "TXT",
        "ttl": 14400,
        "records": [
          { "content": "v=spf1 include:_spf.google.com ~all" }
        ]
      }
    ]
  }'

Validate Before Updating

# Validate records first (returns 200 if valid, 422 if invalid)
curl -X POST "https://developers.hostinger.com/api/dns/v1/zones/example.com/validate" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "overwrite": true,
    "zone": [
      {
        "name": "www",
        "type": "CNAME",
        "ttl": 14400,
        "records": [
          { "content": "example.com." }
        ]
      }
    ]
  }'

Delete Specific DNS Records

curl -X DELETE "https://developers.hostinger.com/api/dns/v1/zones/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "filters": [
      { "name": "www", "type": "A" },
      { "name": "old", "type": "CNAME" }
    ]
  }'

Reset DNS to Defaults

curl -X POST "https://developers.hostinger.com/api/dns/v1/zones/example.com/reset" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sync": true,
    "reset_email_records": false,
    "whitelisted_record_types": ["MX", "TXT"]
  }'

Work with DNS Snapshots

# List available snapshots
curl -X GET "https://developers.hostinger.com/api/dns/v1/snapshots/example.com" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN"

# Get a specific snapshot with contents
curl -X GET "https://developers.hostinger.com/api/dns/v1/snapshots/example.com/42" \
  -H "Authorization: Bearer $HOSTINGER_API_TOKEN"

# Restore from a snapshot
curl -X P
阅读完整来源 ↗