Open-source PHP

Registrar API

One PHP library for managing domains across NameSilo, GoDaddy, Namecheap, and Dynadot — plus a Cloudflare adapter for zones, DNS, and cache. Availability checks, registration, renewals, transfers, DNS records, and nameservers, all through a single consistent interface.

composer require josuamarcelc/registrar-api

Adapters

Supported registrars

Pick an adapter by brand string. All adapters share the same method signatures, so you can switch registrars without rewriting your code.

NameSilo'namesilo'
GoDaddy'godaddy'
Namecheap'namecheap'
Dynadot'dynadot'
CloudflareDNS / zones

Live Demo

Check domain availability

Runs a real checkAvailability() call through the NameSilo adapter, server-side. Enter up to 10 domains separated by commas, spaces, or newlines. Rate-limited to 10 checks per 5 min.

Quick start

Three lines to a working call

<?php
require __DIR__ . '/vendor/autoload.php';

use RegistrarAPI\RegistrarAPI;

$api = RegistrarAPI::make('namesilo', [
  'api_key' => 'YOUR_NAMESILO_API_KEY'
]);

$result = $api->checkAvailability(['example.com', 'mybrand.io']);
print_r($result);

Credentials

Per-adapter config

Each adapter takes a config array. Below is the minimum you usually need.

NameSilo
RegistrarAPI::make('namesilo', [
  'api_key' => 'YOUR_KEY',
]);
GoDaddy
RegistrarAPI::make('godaddy', [
  'api_key'    => 'KEY',
  'api_secret' => 'SECRET',
  // optional: 'base' => 'https://api.godaddy.com/v1'
]);
Namecheap
RegistrarAPI::make('namecheap', [
  'api_user'  => 'USERNAME',
  'api_key'   => 'KEY',
  'client_ip' => 'SERVER_PUBLIC_IP',
  // optional: 'base' => 'https://api.namecheap.com/xml.response'
]);
Dynadot
RegistrarAPI::make('dynadot', [
  'api_key' => 'KEY',
]);

Methods

Common operations

Every adapter implements the same method signatures. Return values are normalized associative arrays.

// Availability
$api->checkAvailability(['example.com']);

// Lifecycle
$api->registerDomain('example.com', [
  'years'      => 1,
  'privacy'    => true,
  'auto_renew' => true,
  'registrant' => [ /* contact fields */ ],
]);
$api->renewDomain('example.com', 1);
$api->transferDomain('example.com', ['auth_code' => 'EPP']);
$api->getDomain('example.com');

// DNS records
$api->getDNS('example.com');
$api->setDNS('example.com', [
  ['type'=>'A',    'host'=>'@',   'value'=>'203.0.113.10', 'ttl'=>600],
  ['type'=>'CNAME','host'=>'www', 'value'=>'@',            'ttl'=>600],
]);
$api->addDNS('example.com', ['type'=>'TXT','host'=>'@','value'=>'v=spf1 -all','ttl'=>300]);
$api->delDNS('example.com', ['type'=>'TXT','host'=>'@']);

// Nameservers
$api->setNameServers('example.com', ['ns1.host.com','ns2.host.com']);

// Escape hatch — call any raw endpoint the adapter doesn't wrap
$api->raw('domains/suggestions?query=mybrand&limit=5');

Response shape

What you get back

okbool — quick success check
rawthe registrar's original parsed payload (JSON or XML-as-array)
httpHTTP status code when available
errtransport-level error string (only when a call fails)
available / unavailable / invalidbuckets populated by checkAvailability()
recordsarray of {type,host,value,ttl,prio?} returned by getDNS()

Bonus

Cloudflare adapter

Same library, same shape, but for zones, DNS records, cache purge, and free toggles (Always HTTPS, Auto HTTPS Rewrites, Brotli, Minify, Rocket Loader, Dev Mode).

$cf = RegistrarAPI::make('cloudflare', ['api_token' => 'CF_TOKEN']);
$cf->createZone('example.com');
$cf->setDNS('example.com', [
  ['type'=>'A','host'=>'@','value'=>'198.51.100.10','ttl'=>300,'proxied'=>true],
]);
$cf->purgeEverything('example.com');

Contribute

Add a new registrar in one file

Create a class in src/adapters/ that extends BaseAdapter and implement the abstract methods. Composer picks it up automatically.

namespace RegistrarAPI\Adapters;

use RegistrarAPI\Core\BaseAdapter;

class MyRegistrar extends BaseAdapter {
  protected string $brand = 'myregistrar';

  public function checkAvailability(array $domains): array { /* ... */ }
  public function registerDomain(string $domain, array $opts): array { /* ... */ }
  public function renewDomain(string $domain, int $years=1, array $opts=[]): array { /* ... */ }
  public function transferDomain(string $domain, array $opts): array { /* ... */ }
  public function getDomain(string $domain): array { /* ... */ }
  public function getDNS(string $domain): array { /* ... */ }
  public function setDNS(string $domain, array $records): array { /* ... */ }
  public function addDNS(string $domain, array $record): array { /* ... */ }
  public function delDNS(string $domain, array $selector): array { /* ... */ }
  public function setNameServers(string $domain, array $nameservers): array { /* ... */ }
  public function raw(string $op, array $params=[]): array { /* ... */ }
}