/bandwidth/get_usage_by_year


GET https://api.sitehost.nz/1.2/bandwidth/get_usage_by_year.json

Gets bandwidth usage of an IP address for a specific year.

Query Parameters

ParameterTypeRequiredDescription
client_idintegerYesThe ID for the client.Example: 1
ip_addrstringYesThe IP address.Example: 192.168.10.1/32
params[from]stringThe from timestamp.Example: 1461131200
params[to]stringThe to timestamp.Example: 1461931200

Code Samples

JavaScript PHP Rails Python
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "https://api.sitehost.nz/1.2/bandwidth/get_usage_by_year.json?apikey=your_key_here&client_id=1&ip_addr=192.168.10.1%2F32&params[from]=1461131200&params[to]=1461931200", false);

xmlHttp.send();

var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.2/bandwidth/get_usage_by_year.json?apikey=your_key_here&client_id=1&ip_addr=192.168.10.1%2F32&params[from]=1461131200&params[to]=1461931200");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'

uri = URI.parse("https://api.sitehost.nz/1.2/bandwidth/get_usage_by_year.json?apikey=your_key_here&client_id=1&ip_addr=192.168.10.1%2F32&params[from]=1461131200&params[to]=1461931200")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
import requests

uri = 'https://api.sitehost.nz/1.2/bandwidth/get_usage_by_year.json?apikey=your_key_here&client_id=1&ip_addr=192.168.10.1%2F32&params[from]=1461131200&params[to]=1461931200'

response = requests.get(uri)

Response

200:

application/json
{
  "return": {
    "192.168.10.1/32": {
      "2014-05-16": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.1436,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-05-23": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 1.0049,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-05": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.2871,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-04-07": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.1436,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-05-14": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.4307,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-05-15": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 1.1484,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-05-20": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.2871,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-05-21": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.2871,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-03": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.1436,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-04": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.7207,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-08": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.4307,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-11": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.2871,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      },
      "2014-06-16": {
        "DOMESTIC": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0.1436,
          "offpeak_out": 0
        },
        "INTERNATIONAL": {
          "peak_in": 0,
          "offpeak_in": 0,
          "peak_out": 0,
          "offpeak_out": 0
        }
      }
    }
  },
  "msg": "Successful",
  "status": true
}