# DNSHE ドメイン API リファレンス
English · 简体中文 · 繁體中文 · 日本語 · Русский · Bahasa Indonesia · Deutsch · Français · 한국어 · العربية
[サービス紹介に戻る](../README_JA.md) ドメイン登録、DNS 管理、動的 IP の更新、アカウント操作を自動化できます。例では DNSHE の API ホストと仮の認証情報を使用しています。名前、ID、認証情報は自分のリソースに置き換えてください。 ## 目次 - [はじめに](#はじめに) - [認証とリクエストの規則](#認証とリクエストの規則) - [ドメイン管理](#ドメイン管理) - [DNS レコード管理](#dns-レコード管理) - [動的 DNS(DDNS)](#動的-dnsddns) - [API キー管理](#api-キー管理) - [ドメインの譲渡](#ドメインの譲渡) - [利用枠](#利用枠) - [WHOIS 検索](#whois-検索) - [エラーとレート制限](#エラーとレート制限) - [クライアントの実装例](#クライアントの実装例) - [セキュリティとよくある質問](#セキュリティとよくある質問) - [サポート](#サポート) ## はじめに ```text https://api005.dnshe.com/index.php?m=domain_hub ``` ベース URL には `m=domain_hub` が含まれます。追加パラメーターには `&` を使ってください。GET のクエリ以外は JSON を使用します。通常の認証付き API は既定で毎分 60 リクエストですが、運営側で変更できます。機能の利用可否はアカウントと設定によります。シェル例は Bash/sh 用です。まず次の環境変数を設定してください。 ```bash export DNSHE_API_KEY='replace-with-your-api-key' export DNSHE_API_SECRET='replace-with-your-api-secret' export DNSHE_DDNS_TOKEN='replace-with-your-ddns-token' ``` ## 認証とリクエストの規則 最初の API キーはクライアントエリア → [ドメイン管理](https://my.dnshe.com/index.php?m=domain_hub) → API 管理で作成します。認証には `X-API-Key` と `X-API-Secret` ヘッダーを使います。URL やボディでの認証情報の送信は無効です。GET パラメーターはクエリ、書き込みパラメーターは `Content-Type: application/json` 付きの JSON ボディで送信します。`endpoint` はリソース、`action` は操作を指定します。`quota` と `whois` に `action` は不要です。DDNS は専用トークンを使用します。 ## ドメイン管理 ### 1.1 ドメイン一覧 `GET` · `endpoint=subdomains` · `action=list` #### パラメーター - `page` — `integer`; 任意; 初期値 / 範囲: `1`. - `cursor_id` — `integer`; 任意. - `per_page` — `integer`; 任意; 初期値 / 範囲: `200; 1–500`. - `include_total` — `boolean`; 任意; 初期値 / 範囲: `false`. - `search` — `string`; 任意. - `rootdomain` — `string`; 任意. - `status` — `string`; 任意; 初期値 / 範囲: `active | suspended | expired`. - `created_from / created_to` — `string`; 任意; 初期値 / 範囲: `YYYY-MM-DD`. - `sort_by` — `string`; 任意; 初期値 / 範囲: `id`. - `sort_dir` — `string`; 任意; 初期値 / 範囲: `desc; asc | desc`. - `fields` — `string`; 任意; 初期値 / 範囲: `all`. `page` は 1 始まりの互換ページ番号です。大量データでは `cursor_id=0` から開始し、`pagination.has_more=true` の間は `pagination.next_cursor_id` を次のカーソルに使います。false で終了します。カーソルモードは OFFSET を使わず ID 順に処理します。`per_page` は既定 200、上限 500、目安は 50–100 です。`include_total=1` は負荷の高い総件数集計を追加します。`search` は接頭辞とルートドメインを検索し、`rootdomain`、`status`、`created_from`、`created_to` で絞り込みます。日付は YYYY-MM-DD です。`sort_by` は `id`、`created_at`、`updated_at`、`expires_at`、`subdomain`、`sort_dir` は `asc` / `desc` に対応します。 `fields` はカンマ区切り、または `all` です。対象は `id`、`subdomain`、`rootdomain`、`full_domain`、`status`、`created_at`、`updated_at`、`expires_at`、`never_expires`、`cloudflare_zone_id`、`provider_account_id` で、独自指定にも `id` が追加されます。`count` は今回返された件数で、検索対象全体の総数とは限りません。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X GET "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=list" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" ``` ```bash curl --fail-with-body --silent --show-error --max-time 30 -X GET "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=list&cursor_id=0&per_page=100&fields=id,subdomain,rootdomain,status" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" ``` ```bash curl --fail-with-body --silent --show-error --max-time 30 -X GET "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=list&search=test&rootdomain=de5.net&status=active&sort_by=expires_at&sort_dir=asc&per_page=50" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" ``` #### レスポンス例 ```json { "success": true, "count": 2, "subdomains": [ { "id": 1, "subdomain": "test", "rootdomain": "de5.net", "full_domain": "test.de5.net", "status": "active", "created_at": "2025-10-19 10:00:00", "updated_at": "2025-10-19 10:00:00" }, { "id": 2, "subdomain": "api", "rootdomain": "de5.net", "full_domain": "api.de5.net", "status": "active", "created_at": "2025-10-19 11:00:00", "updated_at": "2025-10-19 11:00:00" } ] } ``` ```json { "success": true, "count": 1, "subdomains": [ { "id": 901, "subdomain": "test", "rootdomain": "de5.net", "full_domain": "test.de5.net", "status": "active" } ], "pagination": { "mode": "cursor", "page": 1, "per_page": 100, "has_more": true, "cursor_id": 0, "next_cursor_id": 901 } } ``` ### 1.2 ドメイン登録 `POST` · `endpoint=subdomains` · `action=create` #### パラメーター - `subdomain` — `string`; 必須. - `domain` — `string`; 必須. `subdomain` は `myapp` などの接頭辞、`domain` は `de5.net` などの利用可能なルートドメインです。登録には `action=create` と `domain` を使います。レスポンスと一覧フィルターの `rootdomain` は登録用フィールドではありません。空き状況と利用枠の制限が適用されます。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=create" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "subdomain": "myapp", "domain": "de5.net" }' ``` #### レスポンス例 ```json { "success": true, "message": "Subdomain registered successfully", "subdomain_id": 3, "full_domain": "myapp.de5.net" } ``` ### 1.3 ドメイン詳細 `GET` · `endpoint=subdomains` · `action=get` #### パラメーター - `subdomain_id` — `integer`; 必須. 認証したアカウントが所有するドメイン ID を指定します。ドメイン情報、`dns_records`、`dns_count` が返されます。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X GET "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=get&subdomain_id=1" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" ``` #### レスポンス例 ```json { "success": true, "subdomain": { "id": 1, "subdomain": "test", "rootdomain": "de5.net", "full_domain": "test.de5.net", "status": "active", "created_at": "2025-10-19 10:00:00", "updated_at": "2025-10-19 10:00:00" }, "dns_records": [ { "id": 1, "name": "test.de5.net", "type": "A", "content": "203.0.113.10", "ttl": 600, "priority": null, "status": "active", "created_at": "2025-10-19 10:05:00" } ], "dns_count": 1 } ``` ### 1.4 ドメイン削除 `POST / DELETE` · `endpoint=subdomains` · `action=delete` #### パラメーター - `subdomain_id` — `integer`; 必須. 所有ドメインと関連 DNS レコードを削除し、`dns_records_deleted` で削除数を返します。送信前に対象 ID を確認してください。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=delete" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "subdomain_id": 1 }' ``` #### レスポンス例 ```json { "success": true, "message": "Subdomain deleted successfully", "subdomain_id": 1, "full_domain": "test.de5.net", "dns_records_deleted": 4 } ``` ### 1.5 ドメイン更新 `POST / PUT` · `endpoint=subdomains` · `action=renew` #### パラメーター - `subdomain_id` — `integer`; 必須. 通常の DNSHE 無料更新は無料で、例の `charged_amount` は 0 です。汎用プラグインでは有料の復旧を設定できるため、復旧期間中は管理画面の状態と規則を確認してください。結果は `previous_expires_at`、`new_expires_at`、`never_expires`、`remaining_days`、`charged_amount` で判断します。 更新エラーには HTTP 403 の `renewal disabled`、`redemption period requires administrator`、`renewal window expired`、HTTP 422 の `renewal_not_yet_available`、HTTP 402 の `insufficient balance for redemption renewal`、未存在・非所有ドメインの HTTP 404 があります。期間を確認するかサポートに連絡し、連続再試行は避けてください。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=subdomains&action=renew" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "subdomain_id": 3 }' ``` #### レスポンス例 ```json { "success": true, "message": "Subdomain renewed successfully", "subdomain_id": 3, "subdomain": "myapp", "previous_expires_at": "2027-05-01 00:00:00", "new_expires_at": "2028-05-01 00:00:00", "renewed_at": "2027-04-30 00:00:00", "never_expires": 0, "status": "active", "remaining_days": 367, "charged_amount": 0 } ``` ## DNS レコード管理 ### 2.1 DNS レコード一覧 `GET` · `endpoint=dns_records` · `action=list` #### パラメーター - `subdomain_id` — `integer`; 必須. 一覧・作成で返るモジュールの `id` を優先してください。新しい公開レコードでは 15 桁の ID です。`record_id` は DNS プロバイダーの識別子です。変更・削除には少なくとも一方が必要で、両方指定する場合は同じレコードを指す必要があります。不一致は `dns_record_identifier_mismatch` です。旧内部 ID は互換対応し、数字のみの `record_id` は少なくとも 2027-06-12 までの互換性が記載されています。新規実装ではモジュール ID を `id` に指定してください。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X GET "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=dns_records&action=list&subdomain_id=1" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" ``` #### レスポンス例 ```json { "success": true, "count": 2, "records": [ { "id": 1, "record_id": "5a0ce6c4d1d4c71bc5e60a2a2a0e4997", "name": "test.de5.net", "type": "A", "content": "203.0.113.10", "ttl": 600, "priority": null, "line": null, "proxied": false, "status": "active", "created_at": "2025-10-19 10:05:00", "updated_at": "2025-10-19 10:05:00" }, { "id": 2, "name": "www.test.de5.net", "type": "CNAME", "content": "test.de5.net", "ttl": 600, "priority": null, "proxied": false, "status": "active", "created_at": "2025-10-19 10:10:00" } ] } ``` ### 2.2 DNS レコード作成 `POST` · `endpoint=dns_records` · `action=create` #### パラメーター - `subdomain_id` — `integer`; 必須. - `type` — `string`; 必須. - `name` — `string`; 任意; 初期値 / 範囲: `@`. - `content` — `string`; 任意. - `ttl` — `integer`; 任意; 初期値 / 範囲: `600`. - `priority` — `integer`; 任意; 初期値 / 範囲: `MX: 10; SRV: 0`. - `line` — `string`; 任意. - `record_weight / weight` — `integer`; 任意. - `record_port / port` — `integer`; 任意; 初期値 / 範囲: `1–65535`. - `record_target / target` — `string`; 任意. - `caa_flag` — `integer`; 任意; 初期値 / 範囲: `0; 0–255`. - `caa_tag` — `string`; 任意; 初期値 / 範囲: `issue; 1–15 [A-Za-z0-9]`. - `caa_value` — `string`; 任意. `type` は A、AAAA、CNAME、MX、TXT、NS、SRV、CAA に対応します。`name` は登録ドメインからの相対名で、省略・空・`@` はドメイン自体を表します。完全なドメイン名は指定できず、`*` は左端ラベルのみです。`content` は SRV/CAA の構造化入力から組み立てる場合を除き必須です。`ttl` は既定 600 秒、`priority` は MX で 10、SRV で 0 です。 SRV の `record_weight`/`weight`、`record_port`/`port`、`record_target`/`target` は重み、ポート(1–65535)、対象ホストです。対象 `.` はサービス利用不可を表します。CAA は `caa_flag`(0–255、既定 0)、`caa_tag`(英数字 1–15 文字、既定 `issue`)、`caa_value` を使います。`line` は AliDNS 専用で、他のプロバイダーでは空以外の値が拒否されます。 `disable_ns_management` により NS 書き込みが無効な場合があります。外部 DNS に委任されたドメインで非 NS レコードを作成・変更すると `external_dns_delegated` になります。旧レコードの削除、整合処理、期限切れクリーンアップは対象外です。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=dns_records&action=create" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "subdomain_id": 1, "type": "A", "content": "203.0.113.10", "ttl": 600 }' ``` #### レスポンス例 ```json { "success": true, "message": "DNS record created successfully", "id": 738492016583241, "record_id": "5a0ce6c4d1d4c71bc5e60a2a2a0e4997" } ``` ### 2.3 DNS レコード変更 `POST / PUT / PATCH` · `endpoint=dns_records` · `action=modify` #### パラメーター - `id` — `integer`; 任意. - `record_id` — `string`; 任意. - `type / name / content` — `string`; 任意. - `ttl / priority` — `integer`; 任意. - `line` — `string`; 任意. - `record_weight / weight` — `integer`; 任意. - `record_port / port` — `integer`; 任意. - `record_target / target` — `string`; 任意. - `caa_flag` — `integer`; 任意. - `caa_tag / caa_value` — `string`; 任意. `id` または `record_id` と変更対象フィールドを送信します。名前や SRV/CAA の規則は作成と同じです。両識別子は同じレコードを指す必要があります。レスポンスには両方の ID が返ります。 一覧・作成で返るモジュールの `id` を優先してください。新しい公開レコードでは 15 桁の ID です。`record_id` は DNS プロバイダーの識別子です。変更・削除には少なくとも一方が必要で、両方指定する場合は同じレコードを指す必要があります。不一致は `dns_record_identifier_mismatch` です。旧内部 ID は互換対応し、数字のみの `record_id` は少なくとも 2027-06-12 までの互換性が記載されています。新規実装ではモジュール ID を `id` に指定してください。 `disable_ns_management` により NS 書き込みが無効な場合があります。外部 DNS に委任されたドメインで非 NS レコードを作成・変更すると `external_dns_delegated` になります。旧レコードの削除、整合処理、期限切れクリーンアップは対象外です。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=dns_records&action=modify" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "id": 738492016583241, "type": "A", "content": "203.0.113.20", "ttl": 600 }' ``` #### レスポンス例 ```json { "success": true, "message": "DNS record updated successfully", "id": 738492016583241, "record_id": "5a0ce6c4d1d4c71bc5e60a2a2a0e4997" } ``` ### 2.4 DNS レコード削除 `POST / DELETE` · `endpoint=dns_records` · `action=delete` #### パラメーター - `id` — `integer`; 任意. - `record_id` — `string`; 任意. 一覧・作成で返るモジュールの `id` を優先してください。新しい公開レコードでは 15 桁の ID です。`record_id` は DNS プロバイダーの識別子です。変更・削除には少なくとも一方が必要で、両方指定する場合は同じレコードを指す必要があります。不一致は `dns_record_identifier_mismatch` です。旧内部 ID は互換対応し、数字のみの `record_id` は少なくとも 2027-06-12 までの互換性が記載されています。新規実装ではモジュール ID を `id` に指定してください。 #### リクエスト例 ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=dns_records&action=delete" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "id": 1 }' ``` ```bash curl --fail-with-body --silent --show-error --max-time 30 -X POST "https://api005.dnshe.com/index.php?m=domain_hub&endpoint=dns_records&action=delete" \ -H "X-API-Key: ${DNSHE_API_KEY}" \ -H "X-API-Secret: ${DNSHE_API_SECRET}" \ -H "Content-Type: application/json" \ -d '{ "record_id": "5a0ce6c4d1d4c71bc5e60a2a2a0e4997" }' ``` #### レスポンス例 ```json { "success": true, "message": "DNS record deleted successfully" } ``` ## 動的 DNS(DDNS) `GET / POST / PUT` · `endpoint=ddns` · `action=update` ドメイン管理 → DDNS で特定の A/AAAA レコード用トークンを作成します。`Authorization: Bearer