PHP SDK
The ariaservice/arianet Composer package is the official PHP client for the Arianet APIs. It
needs PHP 8.1 or newer with the curl and json extensions and has no other dependencies.
- Source: github.com/ariaservice/arianet-php (current version 0.1.0)
Install
composer require ariaservice/arianet
Until the package is listed on Packagist, add the GitHub repository first:
composer config repositories.arianet vcs https://github.com/ariaservice/arianet-php
composer require ariaservice/arianet:^0.1
Quickstart
Create a personal API token in the panel and export it:
export ARIANET_TOKEN="paste-your-token-here"
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Arianet\Client(); // reads ARIANET_TOKEN
$page = $client->cloud->listServers(['per_page' => 50]);
foreach ($page['data'] as $server) {
echo $server['id'], ' ', $server['name'], ' ', $server['status'], PHP_EOL;
}
API groups
| Property | API |
|---|---|
$client->core | Account, tokens, VPS, SSH keys, firewalls, balance and invoices |
$client->cloud | Arianet Cloud |
$client->regionalVps | Regional VPS |
$client->hosting | Hosting |
$client->baremetal | Dedicated servers |
$client->sms | SMS |
Method names are the camelCase operationId. Arguments come in this order: path parameters, the
JSON body (an array), the query parameters (an array), then $options (idempotency_key,
headers, region). Every method returns the decoded JSON response as arrays.
$server = $client->cloud->createServer([
'name' => 'web-1',
'plan_id' => 101,
'image' => 'ubuntu-24.04',
'datacenter' => 'ovh',
]);
Configuration
$client = new Arianet\Client('token', [
'base_url' => 'https://api.ariaservice.net', // default, or ARIANET_API_URL
'timeout' => 60.0,
'max_retries' => 3,
'max_retry_wait' => 60.0,
]);
max_retries is the number of retries and max_retry_wait the longest wait (seconds) before one
retry. When Retry-After is longer, a RateLimitException is thrown at once. To keep a retried
order safe across process restarts too, pass ['idempotency_key' => '...'] in $options.
Errors
use Arianet\ErrorCode;
use Arianet\Exception\ApiException;
use Arianet\Exception\ConnectionException;
try {
$client->core->createServer($order);
} catch (ApiException $e) {
if ($e->getErrorCode() === ErrorCode::INSUFFICIENT_BALANCE) {
// top up the wallet
}
error_log($e->getStatusCode() . ' ' . $e->getErrorCode() . ': ' . $e->getMessage());
} catch (ConnectionException $e) {
// no answer: DNS, TLS, timeout
}
Each HTTP status has its own exception in Arianet\Exception: AuthenticationException (401),
PaymentRequiredException (402), PermissionDeniedException (403), NotFoundException (404),
ConflictException (409), UnprocessableEntityException (422), RateLimitException (429) and
ServerException (5xx); all extend ApiException. getReason() refines the code on some errors.
Regions and new endpoints
$iran = $client->regionalVps->withRegion('iran-1');
$servers = $iran->listServers();
// Any path, with the same auth, retries and errors:
$client->request('GET', '/cloud/v1/new-endpoint', ['page' => 2]);