Skip to content

Score

PhotoScore is a PhotoILike service that reproduces a market study for a given image and returns, as a result, a score between 0 and 10 (0 being the minimum score and 10 the maximum). This score represents the commercial attractiveness of the image. The higher the score, the more likely it is that the customer will click on it.

Request

POST https://api.photoilike.com/v2.0/score

Headers

Fields

Key Value
Authorization string
Required
Session token preceded by the word Bearer.

Body of the request

The body of the request contains data with the following structure:

JSON representation

{
    "client-key": string,
    "image-url": string,
    "image-base64": string,
    "ext": string
}

Fields

Parameter Information
client-key string
Required
Client-key of the end user requesting the image score.
image-url string
Required1
URL that identifies from where the image to be processed can be obtained.
The image must be obtained through a GET request to the indicated URL.
image-base64 string
Required1
Base64 encoding of the image to be processed.
ext string
Required2
Extension of the file to use. The allowed values are: png, jpg, jpeg, webp, heic, avif.

Warning

1 Each request only processes one image, which implies that the image-url and image-base64 fields are disjoint, i.e., one or the other must be used, but never both at the same time.
2 If image-base64 is used, the ext parameter must be passed.

Response to the request

On success, the HTTP status code in the response header is 200 OK and the response body contains the image score.

JSON representation

{
    "id": string,
    "score": float 
}

Fields

Parameter Information
id string
Identifier of the job that processed the request to obtain the image score.
score float
Score for the request image.

Example of a request

curl --request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer {YOUR.SESSION.TOKEN}" \
--data '{"client-key": "{ACTIVE_CLIENT_KEY}", "image-url": "{https://example.org/photo.jpg}"}' \
https://api.photoilike.com/v2.0/score 
import requests

header = {
    # Add your token session
    'Authorization': 'Bearer YOUR.SESSION.TOKEN'
}

payload = {
    # Add an active client key
    'client-key': 'ACTIVE_CLIENT_KEY',
    # Add the image url you want to rate
    'image-url': 'https://example.org/photo.jpg'
}

endpoint = 'https://api.photoilike.com/v2.0/score'

# Make the request
r = requests.post(endpoint, headers=header, json=payload)

# Response in json format
response = r.json()
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import org.json.JSONObject;

public class Score {

    public static void main(String[] args) throws Exception {
        // add your session token
        String bearerToken = String.format("Bearer %s", "YOUR.SESSION.TOKEN");

        JSONObject payload = new JSONObject();
        // add an active client key
        payload.put("client-key", "ACTIVE_CLIENT_KEY");
        // add the image url you want to rate
        payload.put("image-url", "https://example.org/photo.jpg");


        String endpoint = "https://api.photoilike.com/v2.0/score";

        // build the request
        HttpURLConnection connection = (HttpURLConnection) new URL(endpoint).openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Authorization", bearerToken);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setDoOutput(true);

        OutputStream os = connection.getOutputStream();
        byte[] input = payload.toString().getBytes(StandardCharsets.UTF_8);
        os.write(input, 0, input.length);

        // make the request
        BufferedReader br = new BufferedReader(
                new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)
        );
        StringBuilder response = new StringBuilder();

        for (String responseLine = null; (responseLine = br.readLine()) != null; response.append(responseLine.trim()))
            ;

        // Response in json format
        JSONObject json = new JSONObject(response.toString());
    }

}   
<?php

  // Add your token session
  $headers = array(
    'Content-Type:application/json',
    'Authorization: Bearer YOUR.SESSION.TOKEN'
  );

  // Add an active client key   
  // Add the image url you want to rate
  $payload = json_encode(array(
    'client-key' => 'ACTIVE_CLIENT_KEY',
    'image-url' => 'https://example.org/photo.jpg'
  ));

  $endpoint = "https://api.photoilike.com/v2.0/score";

  $ch = curl_init($endpoint);
  curl_setopt($ch,  CURLOPT_POSTFIELDS, $payload);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  // Make the request
  $result = curl_exec($ch);

  curl_close($ch);

  // Response in json format
  $response = json_decode($result);
 ?>