NAV
shell php python java

Introduction

Welcome to the Neokami API Documentation! Our open API allows you to harness the power of machine learning and cloud computing for your own smart applications and projects.

Image Processing

Gender & Age Detection (Blocking)

ImageAnalyser req=new ImageAnalyser();
String workingDir = System.getProperty("user.dir");

//analyze from Disk
req.setFilePath(workingDir.concat("/data/team1.jpg"));

//analyse from byte array
req.setInputStream(byte[] file)
req.setType("gender");
req.setApiKey("your api key");
req.setWait(1);
req.analyse();
import os
import neokami

req = neokami.ImageAnalyser()
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/data/team1.jpg')
req.setType('gender')
req.setApiKey('your api key here')
req.setWait(1)
analysis = req.analyse()

#get the results
results = analysis.result()
<?php
    $req = new ImageAnalyser();
    $req->setFile(__DIR__.'/data/team1.jpg');
   $req->setType('gender');
    $req->setApiKey('your api key here');
    $req->setWait(1);
    $analysis = $req->analyse();
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "type=gender" -F "wait=1" -F "max_retries=100" -F "sleep=0.4"  https://www.neokami.io/analyse/image

A successful command returns a JSON structure similar to this:

{
   "result":[
      {
         "box":[
            361,
            109,
            41,
            41
         ],
         "gender":"0",
         "min_age":"13",
         "max_age":"18"
      },
      {
         "box":[
            574,
            78,
            55,
            55
         ],
         "gender":"1",
         "min_age":"33",
         "max_age":"45"
      },
      {
         "box":[
            258,
            111,
            58,
            58
         ],
         "gender":"1",
         "min_age":"26",
         "max_age":"35"
      },
      {
         "box":[
            174,
            118,
            53,
            53
         ],
         "gender":"0",
         "min_age":"25",
         "max_age":"43"
      },
      {
         "box":[
            431,
            128,
            55,
            55
         ],
         "gender":"0",
         "min_age":"26",
         "max_age":"36"
      },
      {
         "box":[
            758,
            127,
            58,
            58
         ],
         "gender":"1",
         "min_age":"30",
         "max_age":"41"
      },
      {
         "box":[
            550,
            188,
            54,
            54
         ],
         "gender":"1",
         "min_age":"41",
         "max_age":"55"
      }
   ],
   "warnings":{
      "total_calls":140,
      "retries":8
   },
   "errors":null,
   "status_code":200
}

Description

Blocking calls to the API force the application to wait until Neokami has processed your data. This is useful for decreasing your own applications’ complexity (and vital if the response is required by the next execution step in your code) but comes with the cost of performance and responsiveness.

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For blocking calls, use 1.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
type null string Type of analysis you want to perform. For gender and age detection it has to be set to ‘gender’.
data null binary Image file you want to analyse. All common image formats are supported given a minimum 80x80 pixels size and 20

MB max size.

Response Parameters

Parameter Description Type
box Bounding box for the detected face in the format (x, y, width, height). x and y are the coordinates for the upper left corner of the bounding box. array
gender 0 for female, 1 for male int
min_age Minimum probable age. int
max_age Maximum probable age. int

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Gender & Age Detection (Non-Blocking)

ImageAnalyser req=new ImageAnalyser();
String workingDir = System.getProperty("user.dir");
req.setFilePath(workingDir.concat("/data/team1.jpg"));
req.setType("gender");
req.setApiKey("your api key");
req.setWait(0);
NeokamiResponse analysis=req.analyse();

//Retrieving job results, later on:
String jobId=analysis.getJobIdResult();
req.getResult(jobId);
import os
import neokami

req = neokami.ImageAnalyser()
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/data/team1.jpg')
req.setType('gender')
req.setWait(0)
req.setApiKey('your api key here')
analysis = req.analyse()

#Retrieving job results, later on:
jobId = analysis.result()['job_id']
results = req.getResult(jobId)
<?php
    //Starting a job:
    $req = new ImageAnalyser();
    $req->setFile(__DIR__.'/data/team1.jpg');
   $req->setType('gender');
    $req->setWait(0);
    $req->setApiKey('your api key');
    $analysis = $req->analyseFromDisk();

    //Retrieving job results, later on:
    $jobId = $analysis->result()->job_id;
    $results = $req->getResult($jobId);
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "type=gender" -F "wait=0"  https://www.neokami.io/analyse/image

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "job_id=your_job_id" https://www.neokami.io/engine/job/results

A successful command returns a JSON structure similar to this:

{
   "result":{
      "message":"Payload queued for processing.",
      "job_id":"553de670adf429.73903485"
   },
   "warnings":{
      "total_calls":143,
      "retries":0
   },
   "errors":null,
   "status_code":202
}

Description

Non-blocking calls allow you to start a job on the Neokami Engine and fetch the result at a later time. This is the recommended way of calling the API, as it increases your program responsiveness and allows you to process more data at once (e.g. by iterating through a data set and starting an analysis job for each item).

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For non-blocking calls, use 0.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
type null string Type of analysis you want to perform. For gender and age detection it has to be set to 'gender’.
data null binary Image file you want to analyse. All common image formats are supported given a minimum 80x80 pixels size and 20 MB max size.

Response Parameters

Parameter Description Type
result Short description of the endpoint reply. string
job_id The job id allows you to fetch the job results at a later time. Your results are stored for ten minutes. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Food Detection (Blocking)

ImageAnalyser req=new ImageAnalyser();
String workingDir = System.getProperty("user.dir");

//analyze from Disk
req.setFilePath(workingDir.concat("/data/burger.jpg"));

//analyse from byte array
req.setInputStream(byte[] file)
req.setType("food");
req.setApiKey("your api key");
req.setWait(1);
req.analyse();
import os
import neokami

req = neokami.ImageAnalyser()
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/data/burger.jpg')
req.setType('food')
req.setApiKey('your api key here')
req.setWait(1)
analysis = req.analyse()

#get the results
results = analysis.result()
<?php
   $req = new ImageAnalyser();
   $req->setFile(__DIR__.'/data/burger.jpg');
   $req->setType('food');
   $req->setApiKey('your api key here');
   $req->setWait(1);
   $analysis = $req->analyse();
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "type=food" -F "wait=1" -F "max_retries=100" -F "sleep=0.4"  https://www.neokami.io/analyse/image

A successful command returns a JSON structure similar to this:

{
  "result": [
    {
      "label": "hamburger, beefburger, burger",
      "value": "1.0"
    },
    {
      "label": "won ton, wonton, wonton soup",
      "value": "0.0"
    },
    {
      "label": "potato, white potato, Irish potato, murphy, spud, tater",
      "value": "0.0"
    },
    {
      "label": "spice",
      "value": "0.0"
    },
    {
      "label": "sushi",
      "value": "0.0"
    }
  ],
  "warnings": {
    "total_calls": 9821,
    "retries": 4
  },
  "errors": null,
  "status_code": 200
}

Description

Blocking calls to the API force the application to wait until Neokami has processed your data. This is useful for decreasing your own applications’ complexity (and vital if the response is required by the next execution step in your code) but comes with the cost of performance and responsiveness.

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For blocking calls, use 1.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
type null string Type of analysis you want to perform. For food detection it has to be set to 'food’.
data null binary Image file you want to analyse. All common image formats are supported given a minimum 218x218 pixels size and 20 MB max size.

Response Parameters

Parameter Description Type
label Label describing the food detected. string
value The probability associated with the label. float

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Food Detection (Non-Blocking)

ImageAnalyser req=new ImageAnalyser();
String workingDir = System.getProperty("user.dir");
req.setFilePath(workingDir.concat("/data/burger.jpg"));
req.setType("food");
req.setApiKey("your api key");
req.setWait(0);
NeokamiResponse analysis=req.analyseFromDisk();

//Retrieving job results, later on:
String jobId=analysis.getJobIdResult();
req.getResult(jobId);
import os
import neokami

req = neokami.ImageAnalyser()
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/data/burger.jpg')
req.setType('food')
req.setWait(0)
req.setApiKey('your api key here')
analysis = req.analyse()

#Retrieving job results, later on:
jobId = analysis.result()['job_id']
results = req.getResult(jobId)
<?php
   //Starting a job:
   $req = new ImageAnalyser();
   $req->setFile(__DIR__.'/data/burger.jpg');
   $req->setType('food');
   $req->setWait(0);
   $req->setApiKey('your api key');
   $analysis = $req->analyse();

   //Retrieving job results, later on:
   $jobId = $analysis->result()->job_id;
   $results = $req->getResult($jobId);
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "type=food" -F "wait=0"  http://www.neokami.io/analyse/image

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "job_id=your_job_id" https://www.neokami.io/engine/job/results

A successful command returns a JSON structure similar to this:

{
   "result":{
      "message":"Payload queued for processing.",
      "job_id":"553de670adf429.73903485"
   },
   "warnings":{
      "total_calls":143,
      "retries":0
   },
   "errors":null,
   "status_code":202
}

Description

Non-blocking calls allow you to start a job on the Neokami Engine and fetch the result at a later time. This is the recommended way of calling the API, as it increases your program responsiveness and allows you to process more data at once (e.g. by iterating through a data set and starting an analysis job for each item).

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For non-blocking calls, use 0.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
type null string Type of analysis you want to perform. For food detection it has to be set to 'food’.
data null binary Image file you want to analyse. All common image formats are supported given a minimum 218x218 pixels size and 20 MB max size.

Response Parameters

Parameter Description Type
result Short description of the endpoint reply. string
job_id The job id allows you to fetch the job results at a later time. Your results are stored for ten minutes. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Virtual Cortex (Blocking)

import os
import neokami

req = neokami.VisualCortex()
directory = os.path.dirname(os.path.abspath(__file__))

req.setFile(directory + '/path/to/your/file.jpg')
req.setApiKey('your api key here')
req.setWait(1)
req.setModel('your model identifier')
analysis = req.analyse()

#get the results
results = analysis.result()
<?php
    $req = new VisualCortex();
    $req->setFile(__DIR__.'/path/to/your/file.jpg');
    $req->setApiKey('your api key here');
    $req->setWait(1);
    $req->setModel('your model identifier');
    $analysis = $req->analyse();
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "model=your_model_identifier" -F "wait=1" -F "max_retries=100" -F "sleep=0.4"  https://api.visualcortex.io/cortex/analyse

A successful command returns a JSON structure similar to this:

{
  "result": [
    "classified_label"
  ],
  "warnings": {
    "total_calls": 65,
    "retries": 19
  },
  "errors": null,
  "status_code": 200
}

Description

Blocking calls to the API force the application to wait until Neokami has processed your data. This is useful for decreasing your own applications’ complexity (and vital if the response is required by the next execution step in your code) but comes with the cost of performance and responsiveness.

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For blocking calls, use 1.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
model null string Identifier of the model created on the VisualCortex app (e.g. custom::1).
data null binary Image file you want to analyse. All common image formats are supported given a minimum 227x227 pixels size and 20 MB max size.

MB max size.

Response Parameters

Parameter Description Type
result String specifying the classification label for the uploaded image. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Visual Cortex (Non-Blocking)

import os
import neokami

req = neokami.VisualCortex()
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/path/to/your/file.jpg')
req.setWait(0)
req.setApiKey('your api key here')
req.setModel('your model identifier')
analysis = req.analyse()

#Retrieving job results, later on:
jobId = analysis.result()['job_id']
results = req.getResult(jobId)
<?php
    //Starting a job:
    $req = new VisualCortex();
    $req->setFile(__DIR__.'/path/to/your/file.jpg');
    $req->setWait(0);
    $req->setApiKey('your api key');
    $req->setModel('your model identifier');
    $analysis = $req->analyse();

    //Retrieving job results, later on:
    $jobId = $analysis->result()->job_id;
    $results = $req->getResult($jobId);
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=@/path/to/your/file.jpg" -F "model=your_model_identifier" -F "wait=0"  https://api.visualcortex.io/cortex/analyse

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "job_id=your_job_id" https://api.visualcortex.io/engine/job/results

A successful command returns a JSON structure similar to this:

{
   "result":{
      "message":"Payload queued for processing.",
      "job_id":"553de670adf429.73903485"
   },
   "warnings":{
      "total_calls":143,
      "retries":0
   },
   "errors":null,
   "status_code":202
}

Description

Non-blocking calls allow you to start a job on the Neokami Engine and fetch the result at a later time. This is the recommended way of calling the API, as it increases your program responsiveness and allows you to process more data at once (e.g. by iterating through a data set and starting an analysis job for each item).

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For non-blocking calls, use 0.
max_retries 100 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
model null string Identifier of the model created on VisualCortex app (e.g. custom::1).
data null binary Image file you want to analyse. All common image formats are supported given a minimum 227x227 pixels size and 20 MB max size.

Response Parameters

Parameter Description Type
result Short description of the endpoint reply. string
job_id The job id allows you to fetch the job results at a later time. Your results are stored for ten minutes. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Virtual Cortex (Send Feedback)

import os
import neokami

req = VisualCortex()
req.setApiKey('your api key')

#Send url
url = 'url pointing to an image'
req.setFile(url)
req.setLabel('image label')
feedback = req.sendFeedBack()

#Send base64 encoded image
directory = os.path.dirname(os.path.abspath(__file__))
req.setFile(directory + '/path/to/your/file.jpg')
req.setFeedbackType('base64')
req.setLabel('image label')
feedback = req.sendFeedBack()
<?php
    $req = new VisualCortex();
    $req->setApiKey('your api key');

    //Send url
    $url = 'url pointing to an image';
    $req->setFile($url);
    $req->setLabel('image label');
    $feedback = $req->sendFeedback();

    //Send base64 encoded image
    $req->setFile(__DIR__.'/path/to/your/file.jpg');
    $req->setLabel('image label');
    $req->setFeedbackType('base64');
    $feedback = $req->sendFeedback();
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "data=url_or_base64_encoded_image_string" -F "type=url_or_base64" -F "label=image_label" -F "wait=1" -F "max_retries=5" -F "sleep=0.4"  https://api.visualcortex.io/feedback/image

A successful command returns a JSON structure similar to this:

{
  "result": [
    "Payload queued for processing."
  ],
  "warnings": {
    "total_calls": 65,
    "retries":0
  },
  "errors": null,
  "status_code": 202
}

Description

Send feedback to Neokami with labeled images to create more curated datasets for a particular label.

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For blocking calls, use 1.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
label null string The label is a short description of what the image is.
feedbackType url string Type of the data to be send. The options available are url and base64.
data null string Url or base64 encoded image you want to analyse. All common image formats are supported given a minimum 256x256 pixels size and 20 MB max size.

MB max size.

Response Parameters

Parameter Description Type
result Short description of the endpoint reply. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Text Processing

Sentiment Analysis (Blocking)

SentimentAnalyser req=new SentimentAnalyser();

req.setText("I love hacking with Neokami API. I hate getting up early");
req.setSplitText(1) //optional
req.setApiKey("your api key");
req.setWait(1);
NeokamiResponse analysis=req.analyse();
import neokami

req = SentimentAnalyser()

req.setText("I love hacking with Neokami API. I hate getting up early")
req.setSplitText() #optional
req.setApiKey('your api key here')
req.setWait(1)
analysis = req.analyse()
<?php
   $req = new SentimentAnalyser();
   $req->setText("I love hacking with Neokami API. I hate getting up early");
   $req->setSplitText(); //optional
   $req->setApiKey('your api key here');
   $req->setWait(1);
   $analysis = $req->analyse();
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "text=I love hacking with Neokami API. I hate getting up early" -F "sentences=1" -F "wait=1"  https://neokami/analyse/text/sentiment

A successful command returns a JSON structure similar to this:

{
  "result": [
    {
      "probability": 0.89387685385726,
      "text": "I love hacking with Neokami API.",
      "classification": 1
    },
    {
      "probability": 0.99529025985505,
      "text": "I hate getting up early",
      "classification": -1
    }
  ],
  "warnings": {
    "total_calls": 169,
    "retries": 2
  },
  "errors": null,
  "status_code": 200
}

Description

Blocking calls to the API force the application to wait until Neokami has processed your data. This is useful for decreasing your own applications’ complexity (and vital if the response is required by the next execution step in your code) but comes with the cost of performance and responsiveness.

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For blocking calls, use 1.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
text null string Text you want to analyse.
sentences 0 int If sentences is set to 1, it splits the text in sentences and analyze each sentece separatly. When set to 0, the analysis is performed to the text as a whole.

Response Parameters

Parameter Description Type
probability The probability associated to the text analysed in order be classified as positive or negative. float
text The piece of text analysed. We just get this parameter when we set the parameter 'sentences’ to 1 in the request. int
classification The classification for a piece of text. The text is classsified as positive when the value received is 1 and negative when it is -1 int

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Sentiment Analysis (Non-Blocking)

SentimentAnalyser req=new SentimentAnalyser();

req.setText("I love hacking with Neokami API. I hate getting up early");
req.setSplitText(1) //optional
req.setApiKey("your api key");
req.setWait(0);
NeokamiResponse analysis=req.analyse();

//Retrieving job results, later on:
String jobId=analysis.getJobIdResult();
req.getResult(jobId);
import neokami

req = SentimentAnalyser()

req.setText("I love hacking with Neokami API. I hate getting up early")
req.setSplitText() #optional
req.setApiKey('your api key here')
req.setWait(0)
analysis = req.analyse()

#Retrieving job results, later on:
jobId = analysis.result()['job_id']
results = req.getResult(jobId)
<?php
   //Starting a job
   $req = new SentimentAnalyser();
   $req->setText("I love hacking with Neokami API. I hate getting up early");
   $req->setSplitText(); //optional
   $req->setApiKey('your api key here');
   $req->setWait(0);
   $analysis = $req->analyse();

   //Retrieving job results, later on:
   $jobId = $analysis->result()->job_id;
   $results = $req->getResult($jobId);
?>
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "text=I love hacking with Neokami API. I hate getting up early" -F "sentences=1" -F "wait=0"  https://neokami/analyse/text/sentiment

curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -H "apikey: your_api_key" -F "job_id=your_job_id" https://www.neokami.io/engine/job/results

A successful command returns a JSON structure similar to this:

{
   "result":{
      "message":"Payload queued for processing.",
      "job_id":"553de670adf429.73903485"
   },
   "warnings":{
      "total_calls":143,
      "retries":0
   },
   "errors":null,
   "status_code":202
}

Description

Non-blocking calls allow you to start a job on the Neokami Engine and fetch the result at a later time. This is the recommended way of calling the API, as it increases your program responsiveness and allows you to process more data at once (e.g. by iterating through a data set and starting an analysis job for each item).

Query Parameters

Parameter Default Type Description
api_key null string An API key is required for making calls. Get yours now at www.neokami.com
wait 1 int If set to 0, the API will wait until a result is ready. For non-blocking calls, use 0.
max_retries 0 int If wait is set to 1, max_retries determines how many times the call should attempt to fetch the results before returning.
sleep 0 float Sleep determines the time in seconds between each retry.
text null string Text you want to analyse.
sentences 0 int If sentences is set to 1, it splits the text in sentences and analyze each sentece separatly. When set to 0, the analysis is performed to the text as a whole.

Response Parameters

Parameter Description Type
result Short description of the endpoint reply. string
job_id The job id allows you to fetch the job results at a later time. Your results are stored for ten minutes. string

Response Meta Data - Warnings

Parameter Description Type
total_calls The total number of calls executed with this API key. int
retries How many retries were necessary to fetch the data. int

Response Meta Data - Errors

The errors field provides a convenient method for debugging your API call. Each error generated by the API is represented by a tuple of the following form:

Parameter Description Type
message Human-readable error message. string
fields A key/value pair of parameters that have triggered the error. json

Errors

Neokami uses the following error codes:

Error Code Meaning
400 Bad Request – Your request doesn’t have all the required parameters.
401 Unauthorized – Your API key is de-activated/incorrect.
403 Forbidden – You don’t have the necessary permissions for the function call.
404 Not Found – The specified endpoint could not be found
405 Method Not Allowed – You tried to access an endpoint with an invalid method
406 Not Acceptable – You requested a format that isn’t json.
403 Throttled – Your account has been throttled.
402 Payment Exception – You have used up all your free requests.
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.