API DOCUMENTATION

Overview

The best way to understand the power of PicPurify's API is to try it by using our online demo. You can upload images and see the result.

Satisfied with the result? To get started you will just need to to sign up for an API key. It's quick and easy.

For the detection of specific content, please contact us

>>> Go to single image moderation API doc

>>> Go to video moderation API doc


Single image API

Request

Use a POST request. Below are examples.

Parameters

Parameter Type Description
API_KEY String Personal client API key
task String A task name or a list of tasks separated by comma, to perform : porn_detection, suggestive_nudity_detection, gore_detection, writing_detection, qr_code_detection, money_detection, weapon_detection, drug_detection, nazis_swastika_detection, obscene_gesture_detection, face_gender_detection, face_detection
file_image String Path to the image in your local file system
url_image String URL of the image publicly accessible from internet. Only for tests, can increase latency
reference_id String Optional -A unique reference associated to the image in your information system
origin_id String Optional -A reference to retrieve the origin of the image, profile id, account id ...

Examples

Check an image from local file system
curl -X POST 'https://www.picpurify.com/analyse.php' -F 'API_KEY=XXX' -F 'task=porn_detection,drug_detection,gore_detection' -F 'origin_id=xxxxxxxxx' -F 'reference_id=yyyyyyyy' -F 'file_image=@/path/to/local/file.jpg'
Check an image from url publicly accessible from internet
curl -X POST 'https://www.picpurify.com/analyse.php' -F 'API_KEY=XXX' -F 'task=porn_detection,drug_detection,gore_detection' -F 'origin_id=xxxxxxxxx' -F 'reference_id=yyyyyyyy' -F 'url_image=http://url_image_to_analyse'
Check an image from local file system
picpurify_url = 'https://www.picpurify.com/analyse.php'
img_data = {'file_image': open('/path/to/local/file.jpg', 'rb')}
# if you are using non acsii file names, use the following code instead of the previous line
# img_data = {'file_image': (os.path.basename('/path/to/local/file_speciàl_chàr.jpg').encode('ascii', 'replace'),open('/path/to/local/file_speciàl_chàr.jpg'.decode('utf-8'), 'rb').read())}

result_data = requests.post(picpurify_url,files = img_data, data = {"API_KEY":"XXX", "task":"porn_detection,drug_detection,gore_detection", "origin_id":"xxxxxxxxx", "reference_id":"yyyyyyyy" })
print result_data.content
Check an image from url publicly accessible from internet
picpurify_url = 'https://www.picpurify.com/analyse.php'
result_url = requests.post(picpurify_url,data = {"url_image":"http://url_image_to_analyse", "API_KEY":"XXX", "task":"porn_detection,drug_detection,gore_detection", "origin_id":"xxxxxxxxx", "reference_id":"yyyyyyyy"})
print result_url.content
Check an image from local file system
var request = require('request'),
    fs = require('fs');
var picpurifyUrl = 'https://www.picpurify.com/analyse.php';
var imagePath = '/path/to/local/file.jpg'

var data = {
    file_image: fs.createReadStream(imagePath),
    API_KEY: 'XXX',
    task:"porn_detection,drug_detection,gore_detection",
    origin_id:"xxxxxxxxx", 
    reference_id:"yyyyyyyy" 
   
};

request.post({ url: picpurifyUrl, formData: data }, function (err, httpResponse, body) {
    if (!err && httpResponse.statusCode == 200) {
        console.log(body)
    }
});
Check an image from url publicly accessible from internet
var request = require('request');
var picpurifyUrl = 'https://www.picpurify.com/analyse.php';

request.post(
    picpurifyUrl,
    { form: {url_image:'http://url_image_to_analyse',API_KEY: 'XXX',task:"porn_detection,drug_detection,gore_detection", origin_id:"xxxxxxxxx", reference_id:"yyyyyyyy" } },
    function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
        }
    }
);
Check an image from local file system

$ch = curl_init();

$image_path = "/path/to/local/file.png";
$mime = "image/png";

$cfile = curl_file_create($image_path,$mime);
$data = array('file_image' => $cfile,
		'API_KEY' => "XXX",
		'task' => 'porn_detection,gore_detection',
		 'origin_id' => "xxxxxx",
		 'reference_id' => "yyyyyy"

);

curl_setopt($ch, CURLOPT_URL,'https://www.picpurify.com/analyse.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);

echo $output;
Check an image from url publicly accessible from internet

$ch = curl_init();

$data = array('url_image' => "http://url_image_to_analyse",
		'API_KEY' => "XXX",
		'task' => 'porn_detection,gore_detection',
		'origin_id' => "xxxxx",
		'reference_id' => "yyyyyy"

);

curl_setopt($ch, CURLOPT_URL,'https://www.picpurify.com/analyse.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);

echo $output;


Response

Example response of success filtering:

{  
   "status":"success",
    "final_decision":"OK",
    "confidence_score_decision":0.99155,
   "porn_detection":{  
      "confidence_score":0.99921,
      "compute_time":0.109,
      "porn_content":false
   },
  
   "drug_detection":{  
      "drug_content":false,
      "compute_time":0.11,
      "confidence_score":0.99155
   },
   "gore_detection":{  
      "gore_content":false,
      "compute_time":0.059,
      "confidence_score":1
   },
   "task_call":"porn_detection,gore_detection,drug_detection",
   "reject_criteria":[  

   ],
   "performed":[  
      "porn_detection",
      "gore_detection",
      "drug_detection"
   ],
   "sub_calls":[  
      "porn_detection",
      "gore_detection",
      "drug_detection"
   ],
  
   "media":{  
      "url_image":"http://url_image_to_analyse",
      "file_image":"",
      "media_id":"c4c623de41a52be977233a5bb5c2e8f3",
      "origin_id":"xxxxxxxxx",
      "reference_id":"yyyyyyyy",
   },
   "total_compute_time":0.8219019412994
}
				
Example response of when errors happen:
{
"status":"failure",
"error":
  {
    "errorCode":30,
    "errorMsg":"File is not an image"
  }
}


Result fields Type Description
status String This field indicates if the image is sucessfully analysed. The value can be either 'success' or 'failure'.
final_decision String The result of the final décision "OK" or " KO"
confidence_score_decision Number This value indicates the confidence of the final decision. The value varies from 0.5 to 1.
1 for being very confident; 0.5 for being unsure. In case of "OK" gives the confidence of the classifier with the smallest score, in case of "KO" gives the confidence of the classifier the more responsible of the KO.
sub_calls Array Array of sub_tasks, called to perform the main task
task_call String The main tasks called
total_compute_time String Total server side compute time
media:file_image String File image name
media:url_image String URL of the image publicly accessible from internet.
media:media_id String Picpurify internal media_id generated
media:reference_id String A unique reference associated to the image in your information system
media:origin_id String A reference to retrieve the origin of the image, profile id, account id ...
money_detection:money_content Boolean Does the image contains what the classifier search
money_detection:compute_time Number Compute time of the sub_task
money_detection:confidence_score Number This value indicates the confidence of each classifier on its detection result. The value varies from 0.5 to 1.
1 for being very confident; 0.5 for being unsure.
face_detection:face_coordinate Array Array of the four coordinate of the face, for each face detected in top_left, bottom_right order (xmin,ymin,xmax,ymax). In pixel according to the dimension original_img_height and original_img_width given in parameters.
face_detection:thumbnail_coordinate Array Array of the four coordinate of the computed thumbnail, for each face detected in top, left, bottom, right order. In pixel according to the dimension original_img_height and original_img_width given in parameters.
errorCode Number Error codes.
errorCode:10 (API key error)
errorCode:20 (No url or data information found in the request")
errorCode:30 (Errors in the image to be analysed. E.g., the format is not supported, the size of image is too large, or the size of the file is too big.)
errorCode:50 (Errors of the API service)
errorMsg String Detailed error messages.
Video API

Request

Use a POST request. Below are examples.

Parameters

Parameter Type Description
API_KEY String Personal client API key
task String A task name or a list of tasks separated by comma, to perform : porn_detection, suggestive_nudity_detection, gore_detection, writing_detection, qr_code_detection, money_detection, weapon_detection, drug_detection, nazis_swastika_detection, obscene_gesture_detection, face_gender_detection, face_detection
file_video String Path to the video in your local file system
url_video String URL of the video publicly accessible from internet. Only for tests, can increase latency
frame_interval Decimal Interval in seconds between the analyzed images. The default value is 1, which means that one frame every second will be analyzed. Values less than 1 can be used. For example 0.1 means an image every 100 ms.
reference_id String Optional -A unique reference associated to the image in your information system
origin_id String Optional -A reference to retrieve the origin of the image, profile id, account id ...

Examples

Check an image from local file system
curl -X POST 'https://www.picpurify.com/analyse_video.php' -F 'API_KEY=XXX' -F 'task=porn_detection,drug_detection,gore_detection' -F 'frame_interval=1' -F 'origin_id=xxxxxxxxx' -F 'reference_id=yyyyyyyy' -F 'file_video=@/path/to/local/file.mp4'
Check an image from url publicly accessible from internet
curl -X POST 'https://www.picpurify.com/analyse_video.php' -F 'API_KEY=XXX' -F 'task=porn_detection,drug_detection,gore_detection' -F 'frame_interval=1' -F 'origin_id=xxxxxxxxx' -F 'reference_id=yyyyyyyy' -F 'url_video=http://url_video_to_analyse'
Check an image from local file system
picpurify_url = 'https://www.picpurify.com/analyse_video.php'
video_data = {'file_video': open('/path/to/local/file.mp4', 'rb')}
# if you are using non acsii file names, use the following code instead of the previous line
# video_data = {'file_video': (os.path.basename('/path/to/local/file_speciàl_chàr.jpg').encode('ascii', 'replace'),open('/path/to/local/file_speciàl_chàr.jpg'.decode('utf-8'), 'rb').read())}

result_data = requests.post(picpurify_url,files = video_data, data = {"API_KEY":"XXX", "task":"porn_detection,drug_detection,gore_detection", "frame_interval":1, "origin_id":"xxxxxxxxx", "reference_id":"yyyyyyyy" })
print result_data.content
Check an image from url publicly accessible from internet
picpurify_url = 'https://www.picpurify.com/analyse_video.php'
result_url = requests.post(picpurify_url,data = {"url_video":"http://url_video_to_analyse", "API_KEY":"XXX", "task":"porn_detection,drug_detection,gore_detection", "frame_interval":1, "origin_id":"xxxxxxxxx", "reference_id":"yyyyyyyy"})
print result_url.content
Check an image from local file system
var request = require('request'),
    fs = require('fs');
var picpurifyUrl = 'https://www.picpurify.com/analyse_video.php';
var videoPath = '/path/to/local/file.mp4'

var data = {
    file_video: fs.createReadStream(videoPath),
    API_KEY: 'XXX',
    task:"porn_detection,drug_detection,gore_detection",
    "frame_interval":1,
    origin_id:"xxxxxxxxx", 
    reference_id:"yyyyyyyy" 
   
};

request.post({ url: picpurifyUrl, formData: data }, function (err, httpResponse, body) {
    if (!err && httpResponse.statusCode == 200) {
        console.log(body)
    }
});
Check a video from url publicly accessible from internet
var request = require('request');
var picpurifyUrl = 'https://www.picpurify.com/analyse_video.php';

request.post(
    picpurifyUrl,
    { form: {url_video:'http://url_video_to_analyse',API_KEY: 'XXX',task:"porn_detection,drug_detection,gore_detection",  "frame_interval":1 , origin_id:"xxxxxxxxx", reference_id:"yyyyyyyy" } },
    function (error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
        }
    }
);
Check a video from local file system

$ch = curl_init();

$video_path = "/path/to/local/file.mp4";
$mime = "video/mp4";

$cfile = curl_file_create($video_path,$mime);
$data = array('file_image' => $cfile,
		'API_KEY' => "XXX",
		'task' => 'porn_detection,gore_detection',
		 'frame_interval':1,
		 'origin_id' => "xxxxxx",
		 'reference_id' => "yyyyyy"

);

curl_setopt($ch, CURLOPT_URL,'https://www.picpurify.com/analyse_video.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);

echo $output;
Check a video from url publicly accessible from internet

$ch = curl_init();

$data = array('url_video' => "http://url_video_to_analyse",
		'API_KEY' => "XXX",
		'task' => 'porn_detection,gore_detection',
		'frame_interval':1,
		'origin_id' => "xxxxx",
		'reference_id' => "yyyyyy"

);

curl_setopt($ch, CURLOPT_URL,'https://www.picpurify.com/analyse_video.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);

$output = curl_exec($ch);

echo $output;


Response

Example response of success filtering:

{  
   "task_call": "porn_detection,gore_detection",
    "nb_images": 2,
    "final_decision": "OK",
    "confidence_score_decision": 0.90897,
    "nb_images_ok": 2,
    "nb_images_ko": 0,
  
   "media":{  
      "url_video": "",
        "file_video": "file.mp4",
        "media_id": "94fd30ddb3f3ebc37c1c4649f9d3ff16",
        "reference_id": "xxxxxxxx",
        "origin_id": "yyyyyyyyy"
   },
   "total_compute_time": 2.456799030304,
   
   "images_results": [
        {
            "status": "success",
            "porn_detection": {
                "confidence_score": 0.99996,
                "compute_time": 0.052,
                "porn_content": false
            },
            "confidence_score_decision": 0.81796,
            "gore_detection": {
                "gore_content": false,
                "compute_time": 0.045,
                "confidence_score": 0.81796
            },
            "task_call": "porn_detection,gore_detection",
            "reject_criteria": [],
            "performed": [
                "porn_detection",
                "gore_detection"
            ],
            "sub_calls": [
                "porn_detection",
                "gore_detection"
            ],
            "final_decision": "OK",
            "media": {
                "url_image": "",
                "file_image": "00000001.jpg",
                "media_id": "f0b9a4d75917e9aa9fadd369a9694b6a",
                "reference_id": "xxxxxxxx",
                "origin_id": "yyyyyyyyy"
            },
            "total_compute_time": 0.49649596214294
        },
        {
            "status": "success",
            "porn_detection": {
                "confidence_score": 0.99998,
                "compute_time": 0.072,
                "porn_content": false
            },
            "confidence_score_decision": 0.99998,
            "gore_detection": {
                "gore_content": false,
                "compute_time": 0.069,
                "confidence_score": 1
            },
            "task_call": "porn_detection,gore_detection",
            "reject_criteria": [],
            "performed": [
                "porn_detection",
                "gore_detection"
            ],
            "sub_calls": [
                "porn_detection",
                "gore_detection"
            ],
            "final_decision": "OK",
            "media": {
                "url_image": "",
                "file_image": "00000002.jpg",
                "media_id": "1179cddb6397c8f8fc6c6fc4dc914178",
                "reference_id": "xxxxxxxx",
                "origin_id": "yyyyyyyyy"
            },
            "total_compute_time": 0.4908709526062
        }
    ]
}
				
Example response of when errors happen:
{
"status":"failure",
"error":
  {
    "errorCode":60,
    "errorMsg":"File is not in the good format"
  }
}


Result fields Type Description
final_decision String The result of the final décision "OK" or " KO"
confidence_score_decision Number This value indicates the confidence of the final decision. The value varies from 0.5 to 1.
1 for being very confident; 0.5 for being unsure.
nb_images Number Number of images analyzed in the video file
nb_images_ok Number Number of images that do not contain harmful content
nb_images_ko Number Number of images that contain harmful content
task_call String The main tasks called
total_compute_time String Total server side compute time
media:file_video String File video name
media:url_video String URL of the video publicly accessible from internet.
media:media_id String Picpurify internal media_id generated
media:reference_id String A unique reference associated to the image in your information system
media:origin_id String A reference to retrieve the origin of the image, profile id, account id ...
images_results Array An array with the detail of the results on each frame of the video analyzed
errorCode Number Error codes.
errorCode:10 (API key error)
errorCode:20 (No url or data information found in the request")
errorCode:50 (Errors of the API service)
errorCode:60 (Errors in the video to be analysed. E.g., the format is not supported, the size of the video is too large, or the size of the file is too big.)
errorMsg String Detailed error messages.