PHPackages                             greenreader9/namesilo-php-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. greenreader9/namesilo-php-api

ActiveLibrary

greenreader9/namesilo-php-api
=============================

PHP Wrapper for the NameSilo API

v1.3(1y ago)0421MITPHPPHP &gt;=7.1

Since Sep 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/greenreader9/NameSilo-PHP-API-Wrapper)[ Packagist](https://packagist.org/packages/greenreader9/namesilo-php-api)[ RSS](/packages/greenreader9-namesilo-php-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

NameSilo PHP API Wrapper
========================

[](#namesilo-php-api-wrapper)

PHP Wrapper for the NameSilo API

About Me
--------

[](#about-me)

This PHP class is an API wrapper and supports all current NameSilo function as of September, 2024 (That's actually a lie, everything except for the `bidAuctions` call is supported)

This class was created for private use, but has been released under the MIT license for you to enjoy, because open-source is awesome

That said, it *should* work, but I don't gartentee it. Open a [Issue](https://github.com/greenreader9/NameSilo-PHP-API-Wrapper/issues) or [PR](https://github.com/greenreader9/NameSilo-PHP-API-Wrapper/pulls) to fix any bugs.

Install Me
----------

[](#install-me)

Install via Composer:

> composer require greenreader9/namesilo-php-api

Or grab the /src/NameSiloAPI.php file, that works too

Use Me
------

[](#use-me)

1. Install Me
2. Initiate Me:

```
require_once __DIR__.'/vendor/autoload.php';
use Greenreader9\NameSiloAPI;

$api = new NameSiloAPI('your-api-key', 'application-name', 'bulk', 'ote');
```

`new NameSiloAPI($apiKey, $UserAgent, $BulkORnormal, $SandboxURL)`

`apiKey` is your NameSilo API key. Don't share with others

`UserAgent` is the name of your application. Keep it short and descriptive

`BulkORnormal` (Optional) Set to `"bulk"` to use the [BulkAPI](https://www.namesilo.com/support/v2/articles/account-options/api-automated-batch), `null` or `"normal"` to use the normal API

`SandboxURL` (Optional) Set to `false` or omit for production use. Setting to any other value will set your API call to https://`VALUE`/namesilo.com/`BULK/NORMAL`

> TIP: All commands can use either API type except the `registerDomainDrop` command, which requires the bulk API

> TIP: Sandbox mode does not work during drop/catch times, and does not work with the `registerDomainDrop` command

3. Call a function:

```
$apicall = $api->listDomains();
```

### How to get function name?

[](#how-to-get-function-name)

Vist the API docs:

Go to "Available Operations"

Find the API call you want to make and copy the part of the URL shown below

The URL shown in the docs: `https://www.namesilo.com/api/getPrices?version=1&type=xml&key=12345`

The part you copy: `getPrices` (Otherwise known as the part right after the final slash (`/`)

### How to get the function paramaters?

[](#how-to-get-the-function-paramaters)

Vist the API docs:

Go to "Available Operations"

Find the API call you want to make and scroll to the `Request Parameters` section

The order in which the params are listed on the API page is the order this wrapper accept them (Easy, right?)

#### To omit a paramater

[](#to-omit-a-paramater)

Two ways you can do this:

1. Just don't send it in. If the function has 1 optional param, and no required ones, just do `$api->func()`
2. Set it to null. `$api->func('ThisIsNeeded', null, 'ThisIsAlsoNeeded')`

### What Validation is done?

[](#what-validation-is-done)

Pretty much none. It does check that you used the bulkAPI for `registerDomainDrop`, and that you are not trying to call the `bidAuctions` function. It also requires that you send in all paramaters that NameSilo marks as always required.

Any other mistakes are sent to the NameSilo API, and it will (hopefully) return a helpful error message. See [API Errors Here](https://www.namesilo.com/api-reference) -&gt; Click `Responce Codes`

How to read the responce?
-------------------------

[](#how-to-read-the-responce)

You get the responce as a PHP object (No, I won't provide you support with parsing it, ask Google or consult a PHP book)

Example for the `listDomains` call:

```
object(SimpleXMLElement)#3 (2) {
  ["request"]=> object(SimpleXMLElement)#2 (2) {
    ["operation"]=> string(11) "listDomains"
    ["ip"]=> string(13) "0.0.0.0"
  }
  ["reply"]=> object(SimpleXMLElement)#4 (3) {
    ["code"]=> string(3) "300"
    ["detail"]=> string(7) "success"
    ["domains"]=> object(SimpleXMLElement)#5 (1) {
      ["domain"]=> array(5) {
        [0]=> string(14) "domain1.com"
        [1]=> string(14) "domain2.net"
        [2]=> string(10) "domain3.top"
        [3]=> string(14) "domain4.net"
        [4]=> string(17) "domain5.com"
      }
    }
  }
}

```

And the code that made that responce:

```
