PebbleHost Panel API
Our panel has an API which allows you to manage your server from an automated program, monitor your server, and more!
Calling the API
Our API is accessible through the url https://dedicated.pebblehost.com/api.php
. It accepts a POST request, all parameters are then encoded into the post body.
Parameters are encoded using a querystring format. This means the values are encoded into key=value, each value is url-encoded replacing special characters with their URL equivalent, and multiple keys are joined with a &
character. For example, the following object:
{
"_PebbleHostAPIMethod": "getDedicatedServer",
"_PebbleHostAPIUser": "example@pebblehost.com",
"server_id": 123456,
"_PebbleHostAPIKey": "dGhhbmtzZm9ydXNpbmdwZWJibGVob3N0"
}
Would be encoded as:
_PebbleHostAPIMethod=getDedicatedServer&_PebbleHostAPIUser=example%40pebblehost.com&server_id=123456&_PebbleHostAPIKey=dGhhbmtzZm9ydXNpbmdwZWJibGVob3N0
Authentication
Each request requires three special parameters as well as the actual request data. These are _PebbleHostAPIMethod
, _PebbleHostAPIUser
, and _PebbleHostAPIKey
.
- _PebbleHostAPIMethod - The exact name of the method you wish to use, as detailed below
- _PebbleHostAPIUser - The email of the account
- _PebbleHostAPIKey - A hashed checksum of the authentication data of the request
Calculating the _PebbleHostAPIKey is quite complex as it involves looping through each parameter. First, start with an array/object of your parameters. The first two parameters should be the _PebbleHostAPIMethod and _PebbleHostAPIUser, then any specific arguments such as server_id. Do not include the _PebbleHostAPIKey in this array.
Then, to calculate the _PebbleHostAPIKey, append all the parameters onto a single string without using either =
or &
. For example, with the example object in "Calling the API", you should end up with the following string:
_PebbleHostAPIMethodgetDedicatedServer_PebbleHostAPIUserexample%40pebblehost.comserver_id123456
Next, you will need to make a SHA256 HMAC of this string, encoded using your PebbleHost API Key taken from the dedicated. Here's a code example in Node.JS:
const crypto = require("crypto");
const key = "dGhhbmtzZm9ydXNpbmdwZWJibGVob3N0";
const hmac = crypto.createHmac("sha256", key);
const paramsString = "_PebbleHostAPIMethodgetDedicatedServer_PebbleHostAPIUserexample%40pebblehost.comserver_id123456";
hmac.update(paramsString);
const digest = hmac.digest("hex");
console.log(digest);
// eb121f81247d3bfdd1f88053e8924a983819fa5af6e51609bc8ff27624d80c27
Finally, you would take that generated hash and add it as a _PebbleHostAPIKey
parameter to the request as the last parameter. So in total, for the example request used previously, with an API key of dGhhbmtzZm9ydXNpbmdwZWJibGVob3N0
the final POST body would be:
_PebbleHostAPIMethod=getDedicatedServer&_PebbleHostAPIUser=example%40pebblehost.com&server_id=123456&_PebbleHostAPIKey=eb121f81247d3bfdd1f88053e8924a983819fa5af6e51609bc8ff27624d80c27
Working Example
Here's some sample Node.JS code to make a call to our API:
const axios = require("axios");
const querystring = require('querystring');
const crypto = require("crypto");
async function makeRequest(method, content = {}, user, key) {
let keystr = "";
let params = content ? content : {};
// Add API method & user
params["_PebbleHostAPIMethod"] = method;
params["_PebbleHostAPIUser"] = user;
// Generate string to then HMAC it
for (var param in params) {
if (!params.hasOwnProperty(param)) continue;
keystr += param + params[param].toString();
}
// Creates HMAC of parameters, using PebbleHost API key as message key
let hmac = crypto.createHmac('sha256', key);
hmac.update(keystr);
let digest = hmac.digest('hex');
// Add generated digest to parameters
params["_PebbleHostAPIKey"] = digest;
try {
// Use library to encode parameters into querystring body
const encodedParams = querystring.stringify(params);
// Make request to panel API
const { data } = await axios.post("https://dedicated.pebblehost.com/api.php", encodedParams, {
// Encourage Cloudflare to allow the request
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
'Referer': 'https://dedicated.pebblehost.com'
}
});
return data;
} catch (e) {
throw new Error("API responded with error status " + e.status);
}
}
// Calling the function
(async () => {
const user = "example@pebblehost.com";
const key = "dGhhbmtzZm9ydXNpbmdwZWJibGVob3N0";
const method = "getDedicatedServer";
const content = {'server_id':1};
try {
const response = await makeRequest(method, content, user, key);
console.log("API Response:", JSON.stringify(response, null, 2));
} catch (error) {
console.error("Error calling API:", error.message);
}
})();
API Methods
[
// Dedicated Server Endpoints
'getDedicatedServers' => [],
'getDedicatedServer' => ['server_id'],
'getOSReloads' => [],
'runOSReload' => ['reload_id', 'server_id', 'hostname', 'ip', 'password', ['name' => 'raid', 'default' => null]],
'cancelOSReload' => ['server_id'],
'updateRDNS' => ['server_id', 'ip', 'domain'],
'togglePrivateVLAN' => ['server_id'],
'getPrivateVLAN' => [],
'updateDedicatedServer' => ['server_id', 'nickname', 'client_notes', 'monitoring_level']
];
Parameters
This method doesn't require any parameters.
Sample Response
{
"success": true,
"data": {
"servers": [
{
"id": 1234,
"name": "LON0001",
"nickname": "minecraft1",
"suspended": false,
"primary_ip": "192.168.1.100",
"provisioned_time": "1537840461"
},
{
"id": 1235,
"name": "COV0001",
"nickname": "minecraft2",
"suspended": false,
"primary_ip": "192.168.1.101",
"provisioned_time": "1577840461"
}
]
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
server_id | integer | Yes | Server ID |
Sample Response
{
"success": true,
"data": {
"server": {
"id": 1234,
"name": "LON0001",
"nickname": "minecraft1",
"primary_ip": "192.168.1.100",
"provisioned_time": "1577840461",
"client_notes": "Something interesting",
"suspended": false,
"private_vlan": true,
"port_speed": "1000",
"active_os_reload": false,
"cpu": {
"id": 45,
"name": "Intel Xeon E5-2680v4"
},
"memory": {
"id": 12,
"name": "64GB DDR4"
},
"disks": [
{
"id": 23,
"name": "1TB Gen4 NVMe SSD"
},
{
"id": 24,
"name": "2TB Gen4 NVMe SSD"
}
],
"ips": {
"ipv6": [
{
"ip": "2001:db8::1",
"netmask": "64",
"gateway": "2001:db8::1",
"vmac": "00:11:22:33:44:55",
"rdns": "example3.com",
"cosmicguard": 0
}
],
"ipv4": [
{
"ip": "192.168.1.100",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"vmac": "00:11:22:33:44:55",
"rdns": "example.com",
"cosmicguard": 0
},
{
"ip": "192.168.1.101",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"vmac": "",
"rdns": null,
"cosmicguard": 0
}
]
}
}
}
}
Parameters
This method doesn't require any parameters.
Sample Response
{
"success": true,
"data": {
"os_reloads": [
{
"id": 1,
"name": "Rocky Linux 8"
},
{
"id": 2,
"name": "Ubuntu 22.04 LTS"
},
{
"id": 3,
"name": "Debian 11"
},
{
"id": 4,
"name": "Windows Server 2019"
}
]
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
reload_id | integer | Yes | OS reload profile ID |
server_id | integer | Yes | Server ID |
hostname | string | Yes | Hostname |
ip | string | Yes | IP address |
password | string | Yes | Root/Administrator password |
raid | string | No | RAID configuration (0,1) |
Sample Response
{
"success": true,
"data": {
"message": "OS reload scheduled successfully"
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
server_id | integer | Yes | Server ID |
Sample Response
{
"success": true,
"data": {
"message": "OS reload cancelled successfully"
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
server_id | integer | Yes | Server ID |
ip | string | Yes | IP address |
domain | string | Yes | rDNS |
Sample Response
{
"success": true,
"data": {
"message": "rDNS record updated successfully"
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
server_id | integer | Yes | Server ID |
Sample Response
{
"success": true,
"data": {
"message": "Server added to private VLAN successfully",
"vlan_enabled": true
}
}
Parameters
This method doesn't require any parameters.
Sample Response
{
"success": true,
"data": {
"ips": [
{
"ip": "1.1.1.1",
"gateway": "1.1.1.1",
"subnet_mask": "255.255.255.0",
"cidr": "24",
"type": "ipv4",
"prefix": "1.1.1.1/24",
"rdns": null
},
{
"ip": "1.1.1.2",
"gateway": "1.1.1.1",
"subnet_mask": "255.255.255.0",
"cidr": "24",
"type": "ipv4",
"prefix": "1.1.1.1/24",
"rdns": "example.com"
}
],
"servers": [
{
"id": 1234,
"name": "MinecraftServer1",
"primary_ip": "1.1.1.2"
},
{
"id": 1235,
"name": "MinecraftServer2",
"primary_ip": "1.1.1.3"
}
]
}
}
Parameters
Name | Type | Required | Description |
---|---|---|---|
server_id | integer | Yes | Server ID |
nickname | string | No | Nickname |
client_notes | string | No | Client notes |
monitoring_level | integer | No | Monitoring level (0 = disabled, 1 = enabled) |
Sample Response
{
"success": true,
"data": {
"server": {
"id": 1234,
"name": "COV0001",
"nickname": "MinecraftServer1",
"client_notes": "This is a Minecraft server",
"monitoring_level": 1
}
}
}