This helpdesk article is still work in progress, We're slowly building on a guide on setting up and using the API

Please follow the Multicraft API index for all normal API calls.
You may view their index here: https://www.multicraft.org/site/docs/api

Getting started using the API on our panel

Firstly, make sure you've read through the getting started on the Multicraft API docs, once you've done so you'll need to make a small modification to ensure your application is not blocked by our firewall.

You'll need to head over to your MulticraftAPI.php file and find the following line
curl_setopt ($curl, CURLOPT_POSTFIELDS, $query);

Below this line please add the following code:
curl_setopt ($curl, CURLOPT_HTTPHEADER, array(
'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
'Referer: https://panel.pebblehost.com'
));

It should look like this



Getting a servers Metrics via the API

To start, add the following line to your MulticraftAPI.php file anywhere within the methods array (roughly lines 24 - 122).
'getServerMetrics' => array('id'),

Once added, you may use the following call to get a servers metrics in a raw format:

$api->getServerMetrics(id)

This will return the following.
array (
[Metrics] =>
array (
array (
[time] => epoch time of data
[mem_usage] => memory usage in MB
[cpu_usage] => cpu usage as a percentage (100% = 1 thread)
[netin] => network traffic inbound in Mbps
[netout] => network traffic outbound in Mbps
[disk] => disk usage in GB
),
array (
[time] => epoch time of data
[mem_usage] => memory usage in MB
[cpu_usage] => cpu usage as a percentage (100% = 1 thread)
[netin] => network traffic inbound in Mbps
[netout] => network traffic outbound in Mbps
[disk] => disk usage in GB
),
),
)
Was this article helpful?
Cancel
Thank you!