1.0.12 • Published 4 years ago
@plainhost/api.js v1.0.12
PlainHost Api
Simple API wrapper for PlainHost.xyz
Installation
npm install @plainhost/api.js
You need API Key from PlainHost panel to be able to use this.
How to get Api key
- Visit our hosting panel and login
- Click on the user icon in menu and go to API Credentials
- Set any name and leave the "ALLOWED IPS" field empty, then click on create button
- Copy your key and you can use it
Example of usage
const PlainHost = require('@plainhost/api.js');
const phclient = new PlainHost('USER_API_KEY');
let data = await phclient.getUsage('YOUR_SERVER_ID');
console.log(data);
Methods
getDetails(serverID)
Get all server informations. Ex: NamegetUsage(serverID)
Get the server usage. Ex: RAMsetPowerState(serverID, state)
Start/Stop/Kill/Restart the server remotelycreateBackup(serverID)
Creates a new backup of your servergetBackupDetails(serverID, backupID)
Gives you details about a backup
Used variables:
serverID
= Your Server ID
backupID
= Your Backup ID
state
= Power State (can be: start, stop, restart, kill)