JavaScript / TypeScript SDK
The arianet package is the official JavaScript and TypeScript client for the Arianet APIs.
It uses the built-in fetch, has no runtime dependencies, needs Node.js 20 or newer and ships
type definitions for every method and parameter. It is published as an ES module.
- Source: github.com/ariaservice/arianet-js (current version 0.1.0)
Install
npm install arianet
Until the package is on npm, install it from the GitHub release:
npm install https://github.com/ariaservice/arianet-js/releases/download/v0.1.0/arianet-0.1.0.tgz
Quickstart
Create a personal API token in the panel and export it:
export ARIANET_TOKEN="paste-your-token-here"
import { Client } from "arianet";
const client = new Client(); // reads ARIANET_TOKEN
const page = await client.cloud.listServers({ per_page: 50 });
for (const server of page.data) {
console.log(server.id, server.name, server.status);
}
Keep the token on the server side and never ship it in browser code.
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, the query object (typed as <Group><Method>Query, e.g. CloudListServersQuery), then
RequestOptions (idempotencyKey, headers, region, signal). Every method returns a Promise
of the decoded JSON response.
const server = await client.cloud.createServer({
name: "web-1",
plan_id: 101,
image: "ubuntu-24.04",
datacenter: "ovh",
});
Configuration
const client = new Client({
token: process.env.MY_TOKEN, // default: ARIANET_TOKEN
baseUrl: "https://api.ariaservice.net", // default, or ARIANET_API_URL
timeout: 60_000,
maxRetries: 3,
maxRetryWait: 60_000,
});
timeout and maxRetryWait are in milliseconds. When Retry-After is longer than
maxRetryWait, a RateLimitError is thrown at once with retryAfter (seconds) set. To keep a
retried order safe across process restarts too, pass your own { idempotencyKey }.
Errors
import { APIConnectionError, APIError, ErrorCode } from "arianet";
try {
await client.core.createServer(order);
} catch (err) {
if (err instanceof APIError) {
if (err.code === ErrorCode.INSUFFICIENT_BALANCE) {
// top up the wallet
}
console.error(err.status, err.code, err.message);
} else if (err instanceof APIConnectionError) {
// no answer: DNS, TLS, timeout
} else {
throw err;
}
}
Each HTTP status has its own error class: AuthenticationError (401), PaymentRequiredError
(402), PermissionDeniedError (403), NotFoundError (404), ConflictError (409),
UnprocessableEntityError (422), RateLimitError (429) and InternalServerError (5xx); all
extend APIError. err.reason refines the code on some errors.
Regions and new endpoints
const iran = client.regionalVps.withRegion("iran-1");
const servers = await iran.listServers();
// Any path, with the same auth, retries and errors:
await client.request("GET", "/cloud/v1/new-endpoint", { query: { page: 2 } });