Type-safe Node.js client generated from the Nodesty OpenAPI schema.
npm install @nodesty/api-clientNode.js 18.18 or newer is required. The client also works in runtimes that provide the standard Fetch API.
import { NodestyApiClient } from '@nodesty/api-client';
const client = new NodestyApiClient({
accessToken: process.env.NODESTY_ACCESS_TOKEN,
});
const result = await client.user.getCurrentUser();
if (result.error) {
console.error(result.error.message);
} else {
console.log(result.data);
}Keep personal access tokens in environment variables. Never commit them to source control.
Operations are grouped by their OpenAPI category:
client.userclient.billingclient.virtualServerclient.dedicatedServerclient.firewallclient.mailHosting
Path parameters are positional. A request body is passed as the final data argument:
await client.billing.addOrder('group-id', 'product-id', {
domain: 'example.com',
billingCycle: 'Monthly',
});
await client.virtualServer.performAction('service-id', {
action: 'start',
});
await client.firewall.getAttackLogs('service-id', '203.0.113.10');All parameters, request bodies, response data, and documented errors are fully typed from OpenAPI.
Methods return the parsed API body together with the standard Fetch API Request and Response objects.
Grouped methods and exported SDK functions always use this response shape, including when a custom raw client is configured with responseStyle: 'data'. Use the raw client's request methods directly if you need another response style.
{
data: { /* endpoint response */ },
request: Request,
response: Response, // response.status === 200
}List endpoints return an array in data.
{
data: undefined,
request: Request,
response: Response, // response.status === 204
}{
error: {
error: true,
message: 'Service not found',
statusCode: 404,
statusMessage: 'Not Found',
url: '/api/services/example/vps/info',
},
request: Request,
response: Response, // response.status === 404
}The exact error fields depend on the endpoint. To throw the parsed API error instead of returning it, pass throwOnError in the final options argument:
const user = await client.user.getCurrentUser({ throwOnError: true });
await client.virtualServer.performAction('service-id', { action: 'start' }, { throwOnError: true });The constructor accepts standard Fetch options and supports custom implementations for testing or proxies:
const client = new NodestyApiClient({
accessToken: process.env.NODESTY_ACCESS_TOKEN,
baseUrl: 'https://nodesty.com',
headers: {
'User-Agent': 'my-application/1.0.0',
},
fetch: customFetch,
});The generated low-level SDK functions and request/response types are also exported for advanced integrations.