PHPackages                             bicisteadm/subreg-api-php - 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. [API Development](/categories/api)
4. /
5. bicisteadm/subreg-api-php

ActiveLibrary[API Development](/categories/api)

bicisteadm/subreg-api-php
=========================

Subreg.cz API client for PHP

02PHP

Since Oct 7Pushed 4y agoCompare

[ Source](https://github.com/bicisteadm/subreg-api-php)[ Packagist](https://packagist.org/packages/bicisteadm/subreg-api-php)[ RSS](/packages/bicisteadm-subreg-api-php/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Subreg.cz API client for PHP
============================

[](#subregcz-api-client-for-php)

Package for simple and safe access to [**Subreg.cz API**](https://subreg.cz/manual/).

About Subreg API
----------------

[](#about-subreg-api)

- [**Subreg.cz API Documentation**](https://subreg.cz/manual/)
- [**Subreg.cz API WDSL Specification**](https://subreg.cz/wsdl)

Installation
------------

[](#installation)

Install via Composer:

```
composer install bicisteadm/subreg-api-php
```

It requires PHP version 7.3 and supports PHP up to 7.4.

Access level
------------

[](#access-level)

You can use Package with two ways:

- **raw access**: just call raw command and get raw response – the Package only handle Request authentication, Connection or Server errors and check basic Envelope od Response data.
- **context access**: full service access which is allow traversing over data, checks Request and Response data by strict Schema, access to all properties via strict-typed Getters.

For more information see documentation bellow.

Authentication &amp; Environment
--------------------------------

[](#authentication--environment)

### Authentication

[](#authentication)

For authentication to API use `Credentials` class:

```
$credentials = new \Redbitcz\SubregApi\Credentials('microsoft', 'password');
```

If you are using [Subreg administrator access](https://subreg.cz/en/settings/admins/) to account, use '`#`' to join username and administrator name:

```
$credentials = new \Redbitcz\SubregApi\Credentials('gates#microsoft', 'password');
```

For more information about [administrator access](https://subreg.cz/en/settings/admins/) visit [Subreg API Login documentation page](https://subreg.cz/manual/?cmd=Login).

### Live / Test Environment

[](#live--test-environment)

Package is process all requests to Production Environment.

If you need try your App to [test Environment](https://subreg.cz/manual/?cmd=Main), you can change URL Endpoint:

```
$credentials = new \Redbitcz\SubregApi\Credentials('microsoft', 'password', 'https://ote-soap.subreg.cz/cmd.php');
```

Usage Raw access
----------------

[](#usage-raw-access)

Use `Credentials` object to create `Client`.

```
$client = new \Redbitcz\SubregApi\Client($credentials);
```

Client has only method: `$client->call()` to send authenticated request to Subreg.cz API.

```
$client->call('Check_Domain', ['domain' => 'subreg.cz'])->getData();

/*
    Returns the Array:

    [
      'name' => 'subreg.cz',
      'avail' => 0,
      'price' =>
      [
        'amount' => 165.0,
        'amount_with_trustee' => 165.0,
        'premium' => 0,
        'currency' => 'CZK',
      ],
    ]
*/
```

### Errors

[](#errors)

Client can failures on so many levels.

- **Invalid request** – when you trying submit invalid request, client throws `InvalidRequestException`,
- **Connection problem** – offline, invalid URL, server problem, etc., client throws `ConnectionException`,
- **Server response error** – API server is working, but can't finish your request, domain doesn't exists, etc., client throws `ResponseErrorException`,
- **Another problem with response** – response is missing required fiels, etc., client throws `InvalidResponseException`.

`ResponseErrorException` (and all descendants Exceptions) contains whole response, use:

```
$exception->getResponse();
```

### Response

[](#response)

Response is being wrapped to `Response` envelope for better handling. Response always contains an array.

#### `getData(): array`

[](#getdata-array)

Returns all data from Response as received from API server.

#### `getItem(string $name)`

[](#getitemstring-name)

Returns one item from Response array. If item doesn't exists, returns `null`.

It allows only access to first-level of response array (no recursive access into deep structured data).

#### `hasItem(string $name): bool`

[](#hasitemstring-name-bool)

Returns `true` when item exists in Response, `false` otherwise.

#### `getMandatoryItem(string $name)`

[](#getmandatoryitemstring-name)

Returns one item from Response array. If item doesn't exists, throws `InvalidResponseException`.

### Factory shortcuts

[](#factory-shortcuts)

Creating `Client` instance requires pre-create `Credentials` first.

```
$credentials = new \Redbitcz\SubregApi\Credentials('microsoft', 'password');
$client = new \Redbitcz\SubregApi\Client($credentials);
```

It's can be simplified by `Factory` helper:

```
$client = \Redbitcz\SubregApi\Factory::createClient('microsoft', 'password');
```

If you are using [administrator access](https://subreg.cz/en/settings/admins/) to account, use:

```
$client = \Redbitcz\SubregApi\Factory::createClientForAdministrator('microsoft', 'gates', 'password');
```

### Example

[](#example)

```
$client = \Redbitcz\SubregApi\Factory::createClient('microsoft', 'password');

$response = $client->call('Info_Domain', ['domain' => 'subreg.cz']);

echo "Domain {$response->getItem('name')} is expiring at {$response->getItem('exDate')}.";
// Domain subreg.cz is expiring at 2023-04-22.
```

Usage Context access
--------------------

[](#usage-context-access)

At first create `Context` object instance. Use `Factory` helper for simple create it:

```
$context = \Redbitcz\SubregApi\Factory::createContext('microsoft', 'password');
```

With `Context` object you can access to API resources comfortably by [fluent-like properties](https://dev.to/mofiqul/fluent-interface-and-method-chaining-in-php-and-javascript-251c).

```
foreach ($context->domain()->list() as $domain) {
    echo "Domain {$domain->getName()} is expiring at {$domain->getExpire()->format('Y-m-d')}.\n";
}
// Domain my-first-domain.cz is expiring at 2023-04-22.
// Domain my-second-domain.cz is expiring at 2020-01-01.
// Domain my-third-domain.cz is expiring at 2021-08-30.
// Domain my-fourth-domain.cz is expiring at 2022-01-15.
// Domain my-fifth-domain.cz is expiring at 2020-05-13.
// Domain my-sixth-domain.cz is expiring at 2020-05-13.
```

**NOTE:** Context access is covering only few most-used of [Subreg.cz API commands](https://subreg.cz/manual/).

Work in progress
----------------

[](#work-in-progress)

Package is still under development.

### Future examples in vision

[](#future-examples-in-vision)

Bulk renew of expiring domains:

```
$expiringDomains = $context->domain()->list()->filter(['expire < ' => new DateTime('+ 1 month')]);

foreach ($expiringDomains as $domain) {
    $order = $domain->renew(1); // 1 year
    echo "Domain {$domain->getName()} is renewed by order ID: {$order->getId()}.\n";
}
// Domain my-second-domain.cz is renewed by order ID: 12345000.
// Domain my-fifth-domain.cz is renewed by order ID: 12345001.
// Domain my-sixth-domain.cz is renewed by order ID: 12345002.
```

Remove deprecated SPF record from domains zones for 3th+ level domain:

```
foreach ($context->domain()->list() as $domain) {
    foreach ($domain->dns()->list()->filter(['!isType' => 'SPF', '@getFqn() ~ ' => '/\w+\.\w+\.\w+$/']) as $dnsRecord) {
        $dnsRecord->delete();
        echo "Removed SPF record for {$dnsRecord->getFqn()}.\n";
    }
}
// Removed SPF record for subdomain.my-first-domain.cz.
// Removed SPF record for cluster-1.region-eu.my-thitd-domain.cz.
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/98499faefc3fb55d8e8d9b1616104d5b7bca5bad7786b29b4440d8fc9ebe846a?d=identicon)[bicisteadm](/maintainers/bicisteadm)

---

Top Contributors

[![jakubboucek](https://avatars.githubusercontent.com/u/1657322?v=4)](https://github.com/jakubboucek "jakubboucek (47 commits)")[![soukicz](https://avatars.githubusercontent.com/u/1814750?v=4)](https://github.com/soukicz "soukicz (8 commits)")[![bicisteadm](https://avatars.githubusercontent.com/u/19170948?v=4)](https://github.com/bicisteadm "bicisteadm (2 commits)")

### Embed Badge

![Health badge](/badges/bicisteadm-subreg-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/bicisteadm-subreg-api-php/health.svg)](https://phpackages.com/packages/bicisteadm-subreg-api-php)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k13](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
