Hentai Guru Free Adult Image Hosting


API Guide


Introduction

We have a full featured API allowing you to use all our services from your own website or application.
You can use this API to create your own frontend or let your scripts/programs upload images to us automatically, saving you tons of manual work.
For example if you publish images on your site or blog you can programatically call our API, insert the links in your pages and host your images with us.
A good example to use our API is.. this website! That's right, it's nothing more than a user interface to our own API!

Calling the API

Simply make all your API calls to
http://hosting.hentaiguru.com/api.php
with your parameters. (see below)

Parameters

PARAMETERVALUESDESCRIPTIONREQUIRED
method[post/url]Use post or url for image data.
POST: Upload data from post. Name your data field 'image'.
URL: use url param.
Yes
url-Url to remote image if method=urlOnly if method=url
thumb[0/100/200/300]Thumb size you want, default:0No
color[w/g/b/u/n/r/p/o/i]Background color for viewer page. Colors are:
w => White
g => Gray
b => Black
u => Blue
n => Green
r => Red
p => Pink
o => Orange
i => The official Hentai Guru pattern default:w
No
name-Name for your image to use instead of the filenameNo


Response

All responses are in the JSON format.
There are two possible responses, indicating success or failure.
You will always get status to indicate this.

Positive response example:
{
    "status": "ok",
    "image": "http:\/\/hosting.hentaiguru.com\/view\/w\/f05dacd01224194g\/hosting.gif",
    "name": "hosting",
    "extension": ".gif",
    "thumbnails": {
        "300": {
            "url": "http:\/\/hosting.hentaiguru.com\/thumb\/f05dacd01224194g300\/hosting.jpg",
            "w": 200,
            "h": 200
        }
    }
}


Error response:
{
    "status": "error",
    "error_code": "error_invalid_url",
    "error_msg": "URL is invalid or site does not exist."
}



Examples

For example, we want to upload this image: http://hosting.hentaiguru.com/hosting.png.
We want the blue background and a 200 pix thumbnail. Use the following URL:
hxxp://hosting.hentaiguru.com/api.php?method=url&url=http://hosting.hentaiguru.com/hosting.png&color=u&thumb=200

Thats it! (The response for this request is the poritive response example.)

PHP Examples
<?php
/* Uploading POST data to the API */
$filename = 'image.jpg'; //want to upload this image
$post = array();
$post['file'] = "@".$filename;

//execute curl request
$url = 'http://hosting.hentaiguru.com/api.php?method=post&thumb=200';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

//parse response
$decode = json_decode($response);
$image = $decode->image;
$thumbnail = $decode->thumbnails->{200}->url;

//display it as a clickable thumb
echo "<a href='{$image}'><img src='{$thumbnail}' /></a>";
?>

<?php
/* Simple method to upload image from an URL. */
// URL to the image we want to upload
$url = 'http://hosting.hentaiguru.com/hosting.png';

//Call the API
$api = "http://hosting.hentaiguru.com/api.php?method=url&url=$url"; // 
$response = file_get_contents($api);

//Response
$json = json_decode($response);

if($json->status == 'ok') {
	//We have the image, now we can save it to our database etc.
	echo $json->image;
} elseif($json->status == 'error') {
	//There was an error
	echo $json->error_msg;	
}
?>