Authentication

How to specify your API key

As of IPHub V2, we are promoting the use of the X-Key header. Because our API keys are actually Base64-encoded strings, they’re not practical for GET parameter use as you would have to URL encode it first. Whereas, with the X-Key header, you can send the API key, as is, in your HTTP headers which also leaves you with a prettier request object. The GET parameter key is available too, but strongly discouraged for web applications.

In PHP, you’d do something like this:

<?php
$request = new HttpRequest();
$request->setUrl('http://v2.api.iphub.info/ip/8.8.8.8');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
	'X-Key' => 'YOUR_API_KEY_HERE'
));
try
{
	$response = $request->send();
	echo $response->getBody();
}

catch(HttpException $ex)
{
	echo $ex;
}

The code above was provided as a courtesy to demonstrate the use of the X-Key header, proper integration examples can be found in the integration examples chapter.