β‘ NIC Registry REST API & Live Playground
Explore, test, and integrate the full 37-endpoint global domain provider REST API suite. Live interactive playground, auto-generated SDK snippets, and OpenAPI 3.0 specification.
Registry Health Ping
Check registry availability and operational heartbeat.
https://nic.var.re
{ "note": "Click [Send Request] to execute live call" }
π‘οΈ Developer Security & Integration Guide
1. Bearer Token & Secret Authentication
Every authenticated request requires two HTTP headers:
Authorization: Bearer <API_TOKEN>(orX-API-Token: <API_TOKEN>)X-API-Secret: <API_SECRET>
Tokens are generated inside the Reseller Portal under API Settings.
2. IP Whitelisting (Firewall Rules)
Calls from unauthorized IPs are rejected with 403 IP_NOT_WHITELISTED. The registry firewall supports:
- Single IPv4 addresses:
185.50.69.11 - CIDR subnets:
192.168.1.0/24 - IPv6 addresses:
2a02:4780:1::1 - Global wildcard:
*(Permits any client IP)
3. Header-Only Anti-CSRF Policy
In accordance with Registry Constitution Article 1.3:
- API requests must never include CSRF parameters in the URL (
?cftoken=...) or JSON body. - Requests containing CSRF parameters are rejected immediately with HTTP 403
CSRF_PARAMETER_FORBIDDEN.
4. Standard JSON Response Envelopes
All endpoints strictly adhere to uniform envelope structures:
Success: { "success": true, "data": { ... } }
Error: { "success": false, "error": { "code": "...", "message": "..." } }
π» Runnable REST API Examples (PHP cURL & Python requests)
Select an operation below to view production-ready PHP (cURL) and Python (requests) examples using header-only Bearer & Secret authentication.
π Global Registry EPP Protocol Engine (RFC 5730β5734)
Our registry provides standard, RFC-compliant Extensible Provisioning Protocol (EPP) over HTTP/HTTPS (RFC 5734). Accredited registrars, hosting platforms (WHMCS, Blesta, WiseCP), and automated registry systems can interact with the registry at POST /epp and POST /api/epp using standard XML envelopes.
EPP Result Codes Reference (RFC 5730)
| Code | Category | Meaning / Registry Behavior |
|---|---|---|
1000 | Success | Command completed successfully. |
1001 | Success | Command completed successfully; action pending (e.g., async transfer). |
1300 | Success | Command completed successfully; no messages in poll queue. |
1301 | Success | Command completed successfully; ack to dequeue poll message. |
1500 | Success | Command completed successfully; ending session (<logout/>). |
2001 | Syntax Error | Command syntax error or malformed XML envelope. |
2003 | Parameter Error | Required parameter missing (e.g., missing registrant or period). |
2004 | Parameter Error | Parameter value range error (e.g., invalid period or algorithm). |
2005 | Parameter Error | Parameter value syntax error (e.g., invalid domain or IP format). |
2101 | Unimplemented | Unimplemented command or unsupported object extension. |
2200 | Auth Error | Authentication error (invalid clID, pw, or IP not whitelisted). |
2201 | Auth Error | Authorization error (domain/object belongs to another registrar or invalid authInfo). |
2302 | Object Error | Object exists (domain, host, or contact ID already registered). |
2303 | Object Error | Object does not exist. |
2304 | Object Error | Object status prohibits operation (e.g., clientTransferProhibited). |
2306 | Policy Error | Parameter value policy error (e.g., insufficient reseller wallet balance). |
2400 | Server Error | Command failed due to internal registry or upstream DNS sync error. |
Interactive CLI Testing Tool
Automate or debug EPP requests from the command line using the built-in test client runner.
# Check EPP Greetingphp scripts/epp_client.php --cmd=greeting --pretty
# Check domain availabilityphp scripts/epp_client.php --cmd=domain-check --domain=test.can.re --pretty
# Run custom XML file through HTTP endpointphp scripts/epp_client.php --file=request.xml --url=http://localhost/epp --pretty
Standard HTTP Status Codes & Error Directory
| HTTP Status | Error Code | Condition / Reason |
|---|---|---|
200 OK |
- | Successful read or update operation. |
201 Created |
- | Entity successfully created (domain registration, DNS record, child nameserver, topup request). |
400 Bad Request |
INVALID_INPUT / INSUFFICIENT_BALANCE |
Syntactic validation failure, missing required field, or insufficient reseller balance. |
401 Unauthorized |
API_TOKEN_MISSING / INVALID_API_SECRET |
Missing or invalid Bearer token or failed secret password verification. |
403 Forbidden |
IP_NOT_WHITELISTED / RESELLER_NOT_APPROVED |
Calling IP not permitted, account pending approval/suspended, or CSRF parameter sent in API call. |
404 Not Found |
DOMAIN_NOT_FOUND / RECORD_NOT_FOUND |
Requested domain or resource record does not exist or does not belong to authenticated reseller. |
422 Unprocessable |
TOO_MANY_DOMAINS / UNSUPPORTED_ALGORITHM |
Batch size exceeded (> 50 domains) or unsupported DNSSEC cryptographic algorithm. |
500 Server Error |
INTERNAL_SERVER_ERROR |
Unexpected database exception or upstream Plesk synchronization timeout. |
π¦ Official PHP SDK (NicCanReClient.php)
Zero-dependency PHP 8.1+ client covering all Domain, Contact, Host, DNSSEC, and Wholesale Balance endpoints.
<?php
declare(strict_types=1);
namespace NicCanRe\Sdk;
use RuntimeException;
class NicCanReException extends RuntimeException
{
public function __construct(
string $message,
public readonly int $httpStatus = 0,
public readonly array $responseBody = []
) {
parent::__construct($message, $httpStatus);
}
}
class NicCanReClient
{
private string $baseUrl;
private string $bearerToken;
private string $apiSecret;
private int $timeoutSeconds;
public function __construct(
string $bearerToken,
string $apiSecret,
string $baseUrl = 'https://nic.can.re/api/v1',
int $timeoutSeconds = 20
) {
$this->bearerToken = $bearerToken;
$this->apiSecret = $apiSecret;
$this->baseUrl = rtrim($baseUrl, '/');
$this->timeoutSeconds = $timeoutSeconds;
}
/**
* Execute a signed REST request against the NIC Registry API.
*/
public function request(string $method, string $path, array $payload = []): array
{
$url = $this->baseUrl . '/' . ltrim($path, '/');
$ch = curl_init();
$headers = [
'Authorization: Bearer ' . $this->bearerToken,
'X-API-Secret: ' . $this->apiSecret,
'Accept: application/json',
'Content-Type: application/json',
];
$upperMethod = strtoupper($method);
if ($upperMethod === 'GET' && $payload !== []) {
$url .= '?' . http_build_query($payload);
} elseif ($upperMethod !== 'GET') {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_THROW_ON_ERROR));
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $upperMethod,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $this->timeoutSeconds,
]);
$raw = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);
if ($raw === false) {
throw new NicCanReException('cURL transport error: ' . $err);
}
$decoded = json_decode($raw, true);
if (!is_array($decoded)) {
throw new NicCanReException('Invalid JSON response from registry', $status);
}
if ($status >= 400) {
$msg = $decoded['error']['message'] ?? $decoded['message'] ?? ('HTTP ' . $status);
throw new NicCanReException((string) $msg, $status, $decoded);
}
return $decoded;
}
// --- Domains ---
public function checkDomain(string $domain): array
{
return $this->request('GET', '/domains/check', ['domain' => $domain]);
}
public function registerDomain(string $domain, int $years, array $contacts, array $nameservers, bool $privacy = false): array
{
return $this->request('POST', '/domains', [
'domain' => $domain,
'period' => $years,
'contacts' => $contacts,
'nameservers' => $nameservers,
'privacy' => $privacy,
]);
}
public function getDomainInfo(string $domain): array
{
return $this->request('GET', '/domains/' . rawurlencode($domain));
}
public function renewDomain(string $domain, int $years = 1): array
{
return $this->request('POST', '/domains/' . rawurlencode($domain) . '/renew', ['period' => $years]);
}
public function transferDomain(string $domain, string $authCode, int $years = 1): array
{
return $this->request('POST', '/domains/' . rawurlencode($domain) . '/transfer', [
'auth_code' => $authCode,
'period' => $years,
]);
}
public function restoreDomain(string $domain): array
{
return $this->request('POST', '/domains/' . rawurlencode($domain) . '/restore');
}
public function updateNameservers(string $domain, array $nameservers): array
{
return $this->request('PUT', '/domains/' . rawurlencode($domain) . '/nameservers', ['nameservers' => $nameservers]);
}
// --- DNSSEC ---
public function addDnssec(string $domain, int $keyTag, int $algorithm, int $digestType, string $digest): array
{
return $this->request('POST', '/domains/' . rawurlencode($domain) . '/dnssec', [
'key_tag' => $keyTag,
'algorithm' => $algorithm,
'digest_type' => $digestType,
'digest' => $digest,
]);
}
public function removeDnssec(string $domain, int $keyTag): array
{
return $this->request('DELETE', '/domains/' . rawurlencode($domain) . '/dnssec/' . $keyTag);
}
// --- Contacts & Hosts ---
public function createContact(array $contactData): array
{
return $this->request('POST', '/contacts', $contactData);
}
public function getContact(string $contactId): array
{
return $this->request('GET', '/contacts/' . rawurlencode($contactId));
}
public function createHost(string $hostname, array $ipv4 = [], array $ipv6 = []): array
{
return $this->request('POST', '/hosts', ['hostname' => $hostname, 'ipv4' => $ipv4, 'ipv6' => $ipv6]);
}
// --- Wholesale Billing ---
public function getBalance(): array
{
return $this->request('GET', '/account/balance');
}
public function getTransactions(int $page = 1, int $perPage = 25): array
{
return $this->request('GET', '/account/transactions', ['page' => $page, 'per_page' => $perPage]);
}
}