QuadraNet's new API is accessed via HTTPs POST requests. All requests require the following parameters:
Unless otherwise stated, all requests return a JSON object/array, with a key named "data" which contains the return array.
Unless otherwise stated, all API functions require at least "View" level access to "Devices" in the contact's permissions.
If there is an error with the request, it will return with a key named "error" with a string describing the error.
Some requests which can have specific error information about individual items will instead have a key "errors" within the data array, indexed by id, describing each individual error.
All "list" type functions have the following optional parameters:
Legend (not included in actual parameter names):
Quick PHP Example:
@api_key: API key used to authenticate, generated from the Account Management services page.
Unless otherwise stated, all requests return a JSON object/array, with a key named "data" which contains the return array.
Unless otherwise stated, all API functions require at least "View" level access to "Devices" in the contact's permissions.
If there is an error with the request, it will return with a key named "error" with a string describing the error.
Some requests which can have specific error information about individual items will instead have a key "errors" within the data array, indexed by id, describing each individual error.
All "list" type functions have the following optional parameters:
limit: max number of results to return (for pagination purposes)
offset: start at this result (for pagination purposes), will be ignored if limit is not specified
Legend (not included in actual parameter names):
Parameters prefixed with @: required parameter
Parameters suffixed with []: parameter is an array
Quick PHP Example:
<?php
function do_api_post($url, $post = array()) {
$api_key = 'API_KEY_GOES_HERE';
$post['api_key'] = $api_key;
$post_content = http_build_query($post);
$context_opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n".'Connection: close',
'content' => $post_content,
'timeout' => 5.0,
'follow_location' => false,
'max_redirects' => 0,
),
);
$context = stream_context_create($context_opts);
$data = file_get_contents($url, false, $context);
$json = @json_decode($data);
if ($json === NULL)
return $data;
else
return $json;
}
// API Request Parameters
$post = array(
'device_id' => 1337,
);
// Do the API Request
$data = do_api_post('https://services.quadranet.com/api/device/info', $post));
All Device API functions are accessible at: https://services.quadranet.com/api/device/API_Function
All power related device functions require "Edit" level access to "Devices".
info - Get details about a device or devices.
list - List devices that the contact has access to.
bwgraph - Generate a bandwidth graph for a device.
power_status - Get the power status of a device.
power_cycle - Reboot a device by power cycling it.
power_on - Power on a device.
power_off - Power off a device.
list_nulls - List your IPs that are currently nulled.
null_ip - Null one of your IPs.
unnull_ip - Unnull a currently nulled IP.
All power related device functions require "Edit" level access to "Devices".
info - Get details about a device or devices.
Parameters:
@device_id: device ID/label or array of device IDs to get information for
detail: 1 to give more details about the requested device(s)
credentials: 1 to return the authentication credentials for the requested device(s)
Returns:
Returns an array of devices indexed by device id.
list - List devices that the contact has access to.
Parameters:
detail: 1 to give more details about the device(s)
credentials: 1 to return the authentication credentials for the device(s)
Returns:
Returns an array of devices indexed by device id.
bwgraph - Generate a bandwidth graph for a device.
Parameters:
@device_id: device ID or label to get graph for
period: period of time for graph, one of: hour, day, week, month, lastmonth, year, lastyear
start: if not using period, start time for graph (unix timestamp or string)
end: if not using period, end time for graph (unix timestamp or string)
port: interface to get graph for (eth0, eth1, etc)
title: custom title to use at the top of the graph
width: width of graph to generate
height: height of graph to generate
base64: if set to 1, will return a json array with "graph" key that contains base64 encoded PNG image
Returns:
Directly returns a PNG image of the device BW graph on success (no json), unless supplied with base64 parameter, or standard json error response on failure.
power_status - Get the power status of a device.
Parameters:
@device_id: device ID or label to get power status of
Returns:
An array mapping power port to power state, 0 for off, 1 for on.
power_cycle - Reboot a device by power cycling it.
Parameters:
@device_id: device ID or label to reboot
Returns:
An empty array on success.
power_on - Power on a device.
Parameters:
@device_id: device ID or label to power on
Returns:
An empty array on success.
power_off - Power off a device.
Parameters:
@device_id: device ID or label to power off
Returns:
An empty array on success.
list_nulls - List your IPs that are currently nulled.
Returns:
An array with information about ips that are currently nulled, key nulled_ips contains ip to nulled reason mapping.
null_ip - Null one of your IPs.
Parameters:
@ip: IP address to null
@reason: reason for null
Returns:
An empty array on success.
unnull_ip - Unnull a currently nulled IP.
Parameters:
@ip: IP address to unnull
@reason: reason for unnull
Returns:
An empty array on success.
All DNS API functions are accessible at: https://services.quadranet.com/api/dns/API_Function
domains - Get a list of all domains.
list - Get list of records from a domain (indexed by record id).
records - Return records specified by zone and record id.
new - Create new DNS records for a zone.
update - Update existing DNS records in a zone.
delete - Delete DNS records from a zone.
list_rdns - List Reverse DNS records.
update_rdns - Update Reverse DNS records.
new_zone - Create a new zone.
delete_zone - List Reverse DNS records.
domains - Get a list of all domains.
Parameters:
name: list domains that match a name, wildcards supported
sort_by: zone (default), serial, primary_ns
sort_direction: ascending = 1 (default), decending = 0
limit & offset: see general tab
Returns:
Returns a list of zones/domains.
list - Get list of records from a domain (indexed by record id).
Parameters:
@zone: zone name to get records for (ex: example.com)
host: exact host to get records for (ex: www)
search: treat host parameter is a glob match = 1, normal lookup = 0
type: type of records to list (ex: A)
limit & offset: see general tab
Returns:
Returns an array of dns records, indexed by record id.
records - Return records specified by zone and record id.
Parameters:
@zone: zone name to get records for (ex: example.com))
@records[]: array of record ids
Returns:
Returns an array of dns records, indexed by record id.
new - Create new DNS records for a zone.
Parameters:
@zone: zone name to create new records for (ex: example.com)
@records[]: array of records to create
@type: record type (A, AAAA, CNAME, DNAME, MX, NS, PTR, SPF, SRV, TXT)
@host: hostname of record (ex: www)
@data: record data (ex: 1.2.3.4)
ttl: record Time To Live in seconds, defaults to 3600
priority: record priority, only for MX and SRV records
weight: record weight, only for SRV records
port: port number, only for SRV records
Returns:
If there are any errors with a record, they will be within an "errors" key and no changes will have been made, otherwise an empty array on success
update - Update existing DNS records in a zone.
Parameters:
@zone: zone name to update records for (ex: example.com)
@records[]: array of records to update (indexed by record id)
host: hostname of record (ex: www)
data: record data (ex: 1.2.3.4)
ttl: record Time To Live in seconds, defaults to 3600
priority: record priority, only for MX and SRV records
weight: record weight, only for SRV records
port: port number, only for SRV records
Returns:
If there are any errors with a record, they will be within an "errors" key and no changes will have been made, otherwise an empty array on success
delete - Delete DNS records from a zone.
Parameters:
@zone: zone name to delete records from (ex: example.com)
@records[]: array of records ids to delete
Returns:
If there are any errors with a record, they will be within an "errors" key and no changes will have been made, otherwise an empty array on success
list_rdns - List Reverse DNS records.
Parameters:
cidr: an ip/netmask to get rdns entries for, if no CIDR is specified, it will return a list of availiable CIDRs, if set to "ungrouped", it will return rdns entries for all ips that do not belong to any CIDR.
limit & offset: see general tab
Returns:
Returns an array of ip indexed reverse dns entries, or a list of CIDRs if no CIDR is specified.
update_rdns - Update Reverse DNS records.
Parameters:
@ips[]: associative array of rdns indexed by ip (ex: array('1.2.3.4' => 'reverse.example.com.')
Returns:
If there are any errors with a record, they will be within an "errors" key (indexed by ip) and no changes will have been made, otherwise an empty array on success
new_zone - Create a new zone.
Parameters:
@zone: name of zone to create
ipv4: IPv4 IP to use for premade records, optional
ipv6: IPv6 IP to use for premade records, optional
www: 1 to create www records from ipv4/ipv6 ips supplied, 0 to not
mail: 1 to create mail records from ipv4/ipv6 ips supplied (and an MX record), 0 to not
ftp: 1 to create ftp records from ipv4/ipv6 ips supplied, 0 to not
Returns:
An empty array on success
delete_zone - List Reverse DNS records.
Parameters:
@zone: name of zone to delete.
Returns:
An empty array on success
Coming Soon..