NAV Navbar
Logo
shell python ruby php javascript java

Introduction

Welcome to the MonkeyLearn API! You can use our API to access MonkeyLearn API endpoints to classify, extract or manage your custom modules.

Client Libraries

MonkeyLearn has official client libraries available for the following languages:

Python

The Python client can be installed via pip:

pip install monkeylearn

Ruby

The Ruby client can be installed as a gem:

gem install monkeylearn

Javascript

The Node.js client can be installed via npm:

npm install monkeylearn

PHP

The PHP client can be installed via Composer:

You can use autoloader from Composer by:

{
    "require": {
        "monkeylearn/monkeylearn-php": "~0.1"
    }
}

Or, if you don’t want to use composer, clone the code and include this line of code:

require 'autoload.php';

Java

The Java client can be installed via Maven:

<dependency>
  <groupId>com.monkeylearn</groupId>
  <artifactId>monkeylearn-java</artifactId>
  <version>0.1.4</version>
  <scope>compile</scope>
</dependency>

Or if you want to compile it yourself:

$ git clone git@github.com:monkeylearn/monkeylearn-java

$ cd monkeylearn-java

$ mvn install

You can also download the compiled jar from here.

Authentication

Code snippet

curl -H "Authorization:Token [YOUR_TOKEN_HERE]" \
"[API_ENDPOINT_HERE]"
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE');
?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
    }
}

Make sure to replace [YOUR_TOKEN_HERE] with your API key.

MonkeyLearn uses API keys to allow access to the API. You can register for a new MonkeyLearn API key at our website.

You can find your API key in your account settings.

MonkeyLearn expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization:Token [YOUR_TOKEN_HERE]

Errors

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The various HTTP status codes we might return are listed below.

Error Code Title Description
400 Bad Request Bad request.
401 Unauthorized Your API key is invalid.
404 Not Found The resource does not exist.
422 Validation error You sent an invald request, please verify the data you are sending is correct.
423 Locked The resource that is being accessed is locked.
429 Too Many Requests You reached your request limit per minute or you reached your max concurrent requests limit. Wait the specified time before trying again.
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.

Rate Limiting

Example rate limit error response.

{
    "status_code": 429,
    "detail": "Request was throttled. Expected available in 23 seconds."
}

There is a maximum amount of requests per minute that you can make to the API depending on your plan: 20 for the Free plan, 60 for the Team plan and 120 for the Business plan. The API is limited to 5 concurrent requests per second.

If you are using one of our official API clients, you shouldn’t worry about this limits since the libraries will automatically handle the rate limitation and wait till the resources are available.

Query Limits

Example response headers:

HTTP/1.1 200 OK
Server: nginx/1.6.0
Date: Thu, 09 Apr 2015 19:46:54 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Query-Limit-Remaining: 245
Vary: Accept, Cookie
X-Query-Limit-Request-Queries: 2
Allow: POST, OPTIONS
X-Query-Limit-Limit: 50000

There is a maximum amount of queries that you can make to the API depending on your plan: 500 for the Free plan, 100,000 for the Team plan and 3 Million for the Business plan.

One query is one text analyzed with one module. So, if you send a request with 200 texts for classification, that counts as 200 queries.

In the response of each request, you get some special headers:

Special Header Name
X-Query-Limit-Limit Your current query limit.
X-Query-Limit-Remaining Amount of queries your account has left to use.
X-Query-Limit-Request-Queries Amount of queries consumed by the request.

Classifiers API

Classify

Code snippet

curl --data '{"text_list": ["some text to test", "some more text"]}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
"https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/classify/"
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["This is a text to test your classifier", "This is some more text"]
module_id = '[MODULE_ID]'
res = ml.classifiers.classify(module_id, text_list, sandbox=False)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.classifiers.classify('[MODULE_ID]', ['some text to test', 'some other text'], sandbox: false)
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE');
$text_list = ["This is a text to test your classifier", "This is some more text"];
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->classify($module_id, $text_list, true);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var text_list = ["This is a text to test your classifier", "This is some more text"];
var p = ml.classifiers.classify(module_id, text_list, true);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        String[] textList = {"This is a text to test your classifier", "This is some more text"};
        MonkeyLearnResponse res = ml.classifiers.classify(moduleId, textList, true);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "probability": 0.695,
        "label": "Animals",
        "category_id": 12345
      },
      {
        "probability": 0.789,
        "label": "Mammals",
        "category_id": 12346
      },
      {
        "probability": 0.969,
        "label": "Land Mammals",
        "category_id": 12347
      }
    ],
    [
      {
        "probability": 0.536,
        "label": "Consumer Electronics",
        "category_id": 12348
      },
      {
        "probability": 0.877,
        "label": "Mobile Devices",
        "category_id": 12349
      }
    ]
  ]
}

This endpoint allows you to perform the classification of many text samples using only one request to a custom or public module.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[classifier_id]/classify/

Parameters

Parameter Default Description
sandbox 0 Set this parameter to 1 if you want to use the sandbox to perform the classification.
debug 0 Set this parameter to 1 if you want to use the debug output.

Request body

Parameter Description
text_list A list of texts to classify.

Response

Property Description
result A list of classification results. Each classification result is a list that represents a path in the classification tree starting from the root node and ending in a leaf node.

Classify Multi-Label

Code snippet

curl --data '{"text_list": ["some text to test", "some more text"]}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
"https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/classify/"
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["This is a text to test your classifier", "This is some more text"]
module_id = '[MODULE_ID]'
res = ml.classifiers.classify(module_id, text_list, sandbox=False)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.classifiers.classify('[MODULE_ID]', ['some text to test', 'some other text'], sandbox: false)
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE');
$text_list = ["This is a text to test your classifier", "This is some more text"];
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->classify($module_id, $text_list, true);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var text_list = ["This is a text to test your classifier", "This is some more text"];
var p = ml.classifiers.classify(module_id, text_list, true);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        String[] textList = {"This is a text to test your classifier", "This is some more text"};
        MonkeyLearnResponse res = ml.classifiers.classify(moduleId, textList, true);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      [
        {
          "probability": 0.778,
          "label": "Animals",
          "category_id": 12345
        },
        {
          "probability": 0.843,
          "label": "Mammals",
          "category_id": 12346
        },
        {
          "probability": 0.954,
          "label": "Land Mammals",
          "category_id": 12347
        }
      ],
      [
        {
          "probability": 0.778,
          "label": "Animals",
          "category_id": 12345
        },
        {
          "probability": 0.843,
          "label": "Mammals",
          "category_id": 12346
        },
        {
          "probability": 0.621,
          "label": "Semiaquatic Mammals",
          "category_id": 12348
        }
      ]
    ],
    [
      [
        {
          "probability": 0.536,
          "label": "Consumer Electronics",
          "category_id": 12349
        },
        {
          "probability": 0.877,
          "label": "Mobile Devices",
          "category_id": 12350
        }
      ]
    ]
  ]
}

This endpoint allows you to perform the classification of many text samples using only one request to a custom or public module that you have already installed. This is exactly the same endpoint as the previous “classify” endpoint, but the response is different since it’s for multi-label classifiers.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[classifier_id]/classify/

Parameters

Parameter Default Description
sandbox 0 Set this parameter to 1 if you want to use the sandbox to perform the classification.
debug 0 Set this parameter to 1 if you want to use the debug output.

Request body

Parameter Description
text_list A list of texts to classify.

Response

Property Description
result A list of lists of classification results. Each list of possible classification results (multiple possible labels) is ordered by likelihood. Each classification result is a list that represents a path in the classification tree starting from the root node and ending in a leaf node.

Classifier detail

Code snippet

curl -H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
"https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/?"
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
res = ml.classifiers.detail(module_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.classifiers.detail('[MODULE_ID]')
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->detail($module_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var p = ml.classifiers.detail(module_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        MonkeyLearnResponse res = ml.classifiers.detail(moduleId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {
    "classifier": {
      "hashed_id": "cl_5icAVzKR",
      "name": "Example Classifier",
      "description": "...",
      "train_state": "TRAINED",
      "train_job_id": null
    },
    "sandbox_categories": [
      {
        "id": 1898,
        "name": "root",
        "parent_id": null,
        "accuracy": "0.875325",
        "precision": null,
        "recall": null
     }, {
        "id": 1899,
        "name": "Animals",
        "parent_id": 1898,
        "accuracy": "0.847222",
        "precision": "0.945205",
        "recall": "0.920000"
     }, ...]
  }
}

This endpoint returns the classifier and it’s sandbox categories attributes.

HTTP Request

GET https://api.monkeylearn.com/v2/classifiers/[classifier_id]/

Parameters

This method doesn’t accept parameters.

Response

Property Description
result A dictionary that contains the classifier information and the sandbox categories.

Create Classifier

Code snippet

curl --data '{"name": "New Classifier"}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
res = ml.classifiers.create('Classifier name')
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

Monkeylearn.classifiers.create('New Classifier')
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$res = $ml->classifiers->create('Classifier name');
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var p = ml.classifiers.create('Classifier name');
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        MonkeyLearnResponse res = ml.classifiers.create("Classifier name", "Classifier detail");
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint creates a new classifier.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Default Description
name The name of the new classifier (mandatory).
description The description of the classifier.
language ‘en’ The language of the classifier. It can be one of the following: en, es, fr, de, it, pt, nl, ru, fi, hu, ro, sv, zh, ja, ko, ar, da, no
ngram_range ‘1-1’ The ngram range to be used. It can be ‘1-1’, ‘1-2’, ‘1-3’, ‘2-2’, ‘2-3’, ‘3-3’
use_stemmer true Use stemming.
stop_words A comma separated list of stopwords.
max_features 10000 The maximum amount of features to use.
strip_stopwords true Use stopwords?.
is_multilabel false If the classifier is multi-label or single-label.
is_twitter_data false Optimize for twitter data.
normalize_weights true If true, doesn’t take into account prior probabilities.
classifier ‘nb’ It can be Naive Bayes ‘nb’ or Support Vector Machines ‘svc’

Response

Property Description
result An empty object.

Delete Classifier

Code snippet

curl -X "DELETE" \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
res = ml.classifiers.delete(module_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

Monkeylearn.classifiers.delete('[MODULE_ID]')
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->delete($module_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var p = ml.classifiers.delete(module_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        MonkeyLearnResponse res = ml.classifiers.delete(moduleId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint deletes a classifier. This action cannot be undone.

HTTP Request

DELETE https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/

Parameters

This method doesn’t accept parameters.

Request body

This method doesn’t accept a request body.

Response

Property Description
result An empty object.

Train

Code snippet

curl -X POST \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/train/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
res = ml.classifiers.train(module_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

Monkeylearn.classifiers.train('[MODULE_ID]')
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->train($module_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var p = ml.classifiers.train(module_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        MonkeyLearnResponse res = ml.classifiers.train(moduleId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {"job_id": "ade6825c-86a2-4a7c-a15e-088814c7bd50"}
}

This endpoint allows you to train a classifier.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/train/

Parameters

This method doesn’t accept parameters.

Request body

This method doesn’t accept a request body.

Response

Property Description
result An object with the job id of the training.

Deploy

Code snippet

curl -X POST \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/deploy/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
res = ml.classifiers.deploy(module_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

Monkeylearn.classifiers.deploy('[MODULE_ID]')
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$res = $ml->classifiers->deploy($module_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var p = ml.classifiers.deploy(module_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        MonkeyLearnResponse res = ml.classifiers.deploy(moduleId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint allows you to deploy the current sandbox classifier as the live classifier. Note that the old live classifier will be overwritten.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/deploy/

Parameters

This method doesn’t accept parameters.

Request body

This method doesn’t accept a request body.

Response

Property Description
result An empty object.

List Classifiers

Code snippet

curl -H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
res = ml.classifiers.list()
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

Monkeylearn.classifiers.list()
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$res = $ml->classifiers->list_classifiers();
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var p = ml.classifiers.list();
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        MonkeyLearnResponse res = ml.classifiers.list();
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {
    "classifiers": [
      {
        "classifier": "nb",
        "classifier_type": "custom",
        "description": "Some description",
        "hashed_id": "cl_Tm8onGY8",
        "industry": "other",
        "is_multilabel": false,
        "is_twitter_data": false,
        "language": "en",
        "max_features": 10000,
        "name": "Classifier name",
        "ngram_range": "1-1",
        "normalize_weights": true,
        "permissions": "private",
        "stop_words": "",
        "strip_stopwords": true,
        "text_type": "custom",
        "train_job_id": null,
        "train_state": "UNTRAINED",
        "use_stemmer": true
      }, ...
    ]
  }
}

This endpoint returns the classifier and it’s sandbox categories attributes.

HTTP Request

GET https://api.monkeylearn.com/v2/classifiers/

Parameters

This method doesn’t accept parameters.

Response

Property Description
result A list of dictionaries that contain the information about all your classifiers.

Create Category

Code snippet

curl --data '{"name": "New Category", "parent_id": 1234}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/categories/?
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
parent_category_id = 1000  # use a real category id!!
res = ml.classifiers.categories.create(module_id, 'Category name', parent_category_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

parent_category_id = 1000  # use a real category id

r = Monkeylearn.classifiers.categories.create('[MODULE_ID]', 'Category name', parent_category_id)
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$parent_category_id = 1000;  // use a real category id!!
$res = $ml->classifiers->categories->create($module_id, 'Category name', $parent_category_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var parent_category_id = 1000;  // use a real category id!!
var p = ml.classifiers.categories.create(module_id, 'Category name', parent_category_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        int parentCategoryId = 1000;  // use a real category id!!
        MonkeyLearnResponse res = ml.classifiers.categories.create(moduleId, "Category name",
                                                                    parentCategoryId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint creates a new category on the tree. You have to select a name and a parent category.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[classifier_id]/categories/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
name Category name
parent_id The id of the parent category

(You can get the ids of all the current categories using the “Classifier Detail” endpoint)

Response

Property Description
result Empty Object

Edit Category

Code snippet

curl -X "PATCH" \
--data '{"name": "New category name", "parent_id": 1234}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/categories/2345/?
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
category_id = 1000  # use a real category id!!
new_name = 'New name'
new_parent_id = 1001  # use a real category id!!
res = ml.classifiers.categories.edit(module_id, category_id, new_name, new_parent_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

target_category_id = 1000  # use a real category id!!
new_name = 'New name'
new_parent_id = 1001  # use a real category id!!

Monkeylearn.classifiers.categories.edit('[MODULE_ID]', target_category_id,
                                            new_name, new_parent_id)
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$category_id = 1000;  // use a real category id!!
$new_name = 'New name';  // use a real category id!!
$new_parent_id = 1001;  // use a real category id!!
$res = $ml->classifiers->categories->edit($module_id, $category_id, $new_name, $new_parent_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var category_id = 1000;  // use a real category id!!
var new_name = 'New name';
var new_parent_id = 1001;  // use a real category id!!
var p = ml.classifiers.categories.edit(module_id, category_id, new_name, new_parent_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        int categoryId = 1000;  // use a real category id!!
        String newName = "new name";
        int newParentId = 1001;  // use a real category id!!
        MonkeyLearnResponse res = ml.classifiers.categories.edit(moduleId, categoryId, newName, newParentId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint edits a category from the tree on a classifier.

HTTP Request

PATCH https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/categories/[CATEGORY_ID]/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
name New category name
parent_id The id of the parent category

Response

Property Description
result Empty Object

Delete Category

Code snippet

curl -X "DELETE" \
--data '{"samples-strategy": "move-to", "samples-category-id": 1234}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/categories/2345/?
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
category_id = 1000  # use a real category id!!
res = ml.classifiers.categories.delete(module_id, category_id)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

category_id = 1000  # use a real category id!!

r = Monkeylearn.classifiers.categories.delete('[MODULE_ID]', category_id)
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$category_id = 1000;  // use a real category id!!
$res = $ml->classifiers->categories->delete($module_id, $category_id);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var category_id = 1000;  // use a real category id!!
var p = ml.classifiers.categories.delete(module_id, category_id);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        int categoryId = 1000;  // use a real category id!!
        MonkeyLearnResponse res = ml.classifiers.categories.delete(moduleId, categoryId);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoint deletes a category from the tree. This action cannot be undone.

HTTP Request

DELETE https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/categories/[CATEGORY_ID]/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
samples-strategy Choose what to do with the samples of the deleted category. Options are: “move-to-parent” or “move-to”. If you select “move-to” then also have to set the “samples-category-id” paremeter with the id of the category where you want to move the samples.
samples-category-id In case you choose “move-to” as samples-strategy, set the id of the category you want to move the samples to.

Response

Property Description
result Empty Object

Upload samples

Code snippet

curl --data '{"samples": [{"text": "Text1", "category_path": "A/B"}]}'  \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/samples/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
module_id = '[MODULE_ID]'
category_id_1 = 1000  # Use real category ids!
category_id_2 = 1001  # Use real category ids!
samples = [
    ('The movie was terrible, I hated it.', category_id_1),
    ('I love this movie, I want to watch it again!', category_id_2),
    ('You can also specify the category path instead of the id', '/A/B')
]
res = ml.classifiers.upload_samples(module_id, samples)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

positive_category_id = 1000  # Use real category ids, use the classifier detail endpoint
negative_category_id = 1001  # Use real category ids, use the classifier detail endpoint

samples = [
    ['Nice beatiful', positive_category_id],
    ['awesome excelent', positive_category_id],
    ['Awful bad', negative_category_id],
    ['sad pale', negative_category_id],
    ['happy sad both multilabel', [positive_category_id, negative_category_id]]
]
r = Monkeylearn.classifiers.upload_samples('[MODULE_ID]', samples)
<?php

require 'autoload.php';

$ml = new MonkeyLearn\Client('[YOUR_TOKEN_HERE]');
$module_id = '[MODULE_ID]';
$category_id_1 = 1000;  // Use real category ids!
$category_id_2 = 1001;  // Use real category ids!
$samples = array(
    array('The movie was terrible, I hated it.', $category_id_1),
    array('I love this movie, I want to watch it again!', $category_id_2),
    array('You can also specify the category path instead of the id', '/A/B')
);
$res = $ml->classifiers->upload_samples($module_id, $samples);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = '[MODULE_ID]';
var category_id_1 = 1000;  // Use real category ids!
var category_id_2 = 1001;  // Use real category ids!
var samples = [
    ['The movie was terrible, I hated it.', category_id_1],
    ['I love this movie, I want to watch it again!', category_id_2],
    ['You can also specify the category path instead of the id', '/A/B']
];
var p = ml.classifiers.uploadSamples(module_id, samples);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;
import com.monkeylearn.Tuple;

import java.util.ArrayList;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "[MODULE_ID]";
        ArrayList samples = new ArrayList();
        int category_id_1 = 1000;  // Use real category ids!
        int category_id_2 = 1001;  // Use real category ids!


        samples.add(new Tuple<String, Integer>("The movie was terrible, I hated it.",
                                               category_id_1));

        samples.add(new Tuple<String, Integer>("I love this movie, I want to watch it again!",
                                               category_id_2));
        samples.add(new Tuple<String, String>("You can also specify the category path instead of the id.", "/A/B"));
        MonkeyLearnResponse res = ml.classifiers.uploadSamples(moduleId, samples);
        System.out.println( res.jsonResult );
    }
}

Example response body

{
  "result": {}
}

This endpoints allows you to upload samples to one or more categories.

HTTP Request

POST https://api.monkeylearn.com/v2/classifiers/[MODULE_ID]/samples/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
samples A list of objects with the sample text (text property) and the ID of the category that sample should be saved to (category_id property). In the case it’s a multi-label classifier, the category_id can also be a list of ids. You can also use category_path instead of category_id to upload the sample to the specified path.

Response

Property Description
result Empty Object

Extractors API

Keywords Extractor

Code snippet

curl --data '{"text_list": ["Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look."]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_y7BPYzNG/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look."]
module_id = 'ex_y7BPYzNG'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_y7BPYzNG', ['Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look.'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look."];
$module_id = 'ex_y7BPYzNG';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_y7BPYzNG';
var text_list = ["Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look."];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_y7BPYzNG";
        String[] textList = {"Elon Musk has shared a photo of the spacesuit designed by SpaceX. This is the second image shared of the new design and the first to feature the spacesuit’s full-body look."};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "count": 2,
        "relevance": "0.952",
        "positions_in_text": [
          36,
          145
        ],
        "keyword": "spacesuit"
      },
      {
        "count": 1,
        "relevance": "0.714",
        "positions_in_text": [
          0
        ],
        "keyword": "Elon Musk"
      },
      {
        "count": 1,
        "relevance": "0.714",
        "positions_in_text": [
          157
        ],
        "keyword": "full-body look"
      },
      {
        "count": 1,
        "relevance": "0.714",
        "positions_in_text": [
          78
        ],
        "keyword": "second image"
      },
      {
        "count": 1,
        "relevance": "0.714",
        "positions_in_text": [
          105
        ],
        "keyword": "new design"
      },
      {
        "count": 1,
        "relevance": "0.476",
        "positions_in_text": [
          23
        ],
        "keyword": "photo"
      },
      {
        "count": 1,
        "relevance": "0.476",
        "positions_in_text": [
          58
        ],
        "keyword": "SpaceX"
      }
    ]
  ]
}

Extract keywords from a list of texts in English. In case you want to extract keywords from texts in Spanish, use ex_eV2dppYE instead of ex_y7BPYzNG.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_y7BPYzNG/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Default Description
text_list A list of texts from which to extract keywords.
max_keywords 10 The maximum amount of keywords to extract.
use_stemming true Take words to their base form in order to get better results.
use_idfs true Use a language model for computing the Inverse Document Frequencies.
lowercase false Lowercase all the given text.
use_company_names false Expand company names, if in the text appears the word ‘Google’ and in other part appears ‘Google Inc.’, the word ‘Google’ will be expanded to ‘Google Inc.’.
expand_acronyms false Expand acronyms to they full form, for example ‘USA’ to ‘United States of America’ if both tokens appear in the given text.
keep_ampersand false Keep the ‘&’ char when it appears inside a name. For example ‘Ferrara & Wolf’.

Response

Property Description
result A list of the extracted keywords and their relevance.

Boilerplate Extractor

Code snippet

curl --data '{"text_list": ["<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>"]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_RK5ApHnN/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>"]
module_id = 'ex_RK5ApHnN'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_RK5ApHnN', ['<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>"];
$module_id = 'ex_RK5ApHnN';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_RK5ApHnN';
var text_list = ["<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>"];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_RK5ApHnN";
        String[] textList = {"<!DOCTYPE html>\r\n<head><meta charset=\"UTF-8\"><\/head>\r\n<body>\r\n<h1>Ford disguised a man as a car seat to research self-driving <\/h1>\r\n<p id=\"speakable-summary\">Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle.<\/p>\r\n<p>The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop.\r\n<\/body>\r\n<\/html>"};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "is_header": true,
        "paragraph_text": "Ford disguised a man as a car seat to research self-driving | TechCrunch"
      },
      {
        "is_header": false,
        "paragraph_text": "Yes, you read that correctly: Ford put a man in a car seat disguise so that a Ford Transit could masquerade as a true self-driving vehicle. Why? To evaluate how passers-by, other drivers on the road and cyclists reacted to sharing the road with an autonomous vehicle."
      },
      {
        "is_header": false,
        "paragraph_text": "The trial, conducted with the Virginia Tech Transportation Institute, also made use of a light bar mounted on the top of the windshield to provide communication about what the car was doing, including yielding, driving autonomously or accelerating from a full stop."
      }
    ]
  ]
}

Extract relevant text from a list of HTML’s. This algorithm can be used to detect and remove the surplus “clutter” (boilerplate, templates) around the main textual content of a web page.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_RK5ApHnN/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
text_list A list of htmls from which to extract the texts.

Response

Property Description
result A list that contains for each html a list of different relevant paragraphs inside the html indicating whether they are headers or not.

Entity Extractor

Code snippet

curl --data '{"text_list": ["SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars."]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_isnnZRbS/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars."]
module_id = 'ex_isnnZRbS'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_isnnZRbS', ['SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars.'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars."];
$module_id = 'ex_isnnZRbS';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_isnnZRbS';
var text_list = ["SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars."];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_isnnZRbS";
        String[] textList = {"SpaceX is an aerospace manufacturer and space transport services company headquartered in California. It was founded in 2002 by entrepreneur and investor Elon Musk with the goal of reducing space transportation costs and enabling the colonization of Mars."};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "count": 1,
        "tag": "ORGANIZATION",
        "entity": "SpaceX"
      },
      {
        "count": 1,
        "tag": "PERSON",
        "entity": "Elon Musk"
      },
      {
        "count": 1,
        "tag": "LOCATION",
        "entity": "California"
      },
      {
        "count": 1,
        "tag": "LOCATION",
        "entity": "Hawthorne"
      },
      {
        "count": 1,
        "tag": "LOCATION",
        "entity": "Mars"
      }
    ]
  ]
}

Extract Entities from a list of texts using Named Entity Recognition (NER). NER labels sequences of words in a text which are the names of things, such as person and company names. This implementation labels 3 classes: PERSON, ORGANIZATION and LOCATION.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_isnnZRbS/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
text_list A list of texts from which to extract the entities.

Response

Property Description
result A list that contains for each text, a list of the different entities extracted with their type.

Spanish Entity Extractor

Code snippet

curl --data '{"text_list": ["Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías."]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_Kc8uzhSi/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías."]
module_id = 'ex_Kc8uzhSi'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_Kc8uzhSi', ['Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías.'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías."];
$module_id = 'ex_Kc8uzhSi';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_Kc8uzhSi';
var text_list = ["Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías."];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_Kc8uzhSi";
        String[] textList = {"Tesla es una compañía ubicada en Silicon Valley y fundada por el emprendedor Elon Musk que diseña, fabrica y vende coches eléctricos, componentes para la propulsión de vehículos eléctricos y sistemas de almacenamiento a baterías."};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "count": 1,
        "tag": "ORG",
        "entity": "Tesla"
      },
      {
        "count": 1,
        "tag": "PERS",
        "entity": "Elon Musk"
      },
      {
        "count": 1,
        "tag": "LUG",
        "entity": "Silicon Valley"
      }
    ]
  ]
}

Extract Entities from a list of texts in Spanish using Named Entity Recognition (NER). NER labels sequences of words in a text which are the names of things, such as person and company names. This implementation labels 4 classes: PERS, ORG, LUG and OTROS.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_Kc8uzhSi/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
text_list A list of texts from which to extract the entities.

Response

Property Description
result A list that contains for each text, a list of the different entities extracted with their type.

US Address Extractor

Code snippet

curl --data '{"text_list": ["Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”."]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_dGiEqzyF/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”."]
module_id = 'ex_dGiEqzyF'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_dGiEqzyF', ['Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”.'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”."];
$module_id = 'ex_dGiEqzyF';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_dGiEqzyF';
var text_list = ["Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”."];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_dGiEqzyF";
        String[] textList = {"Facebook is moving its headquarters. The address of the new location is 1 Hacker Way, as seen on a brand new business card of a Facebook employee, the address epitomizes the company’s internal motto “Move Fast and Break Things”."};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      [
        [
          "1",
          "address_number"
        ],
        [
          "Hacker",
          "street_name"
        ],
        [
          "Way,",
          "street_name_post_type"
        ]
      ]
    ]
  ]
}

Extract US addresses from text. This algorithm can be used to detect a single or multiple addresses inside a text and extract information about them.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_dGiEqzyF/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
text_list A list of texts from which to extract the entities.

Response

Property Description
result A list that contains for each text, a list of the different entities extracted with their type.

Sentence Extractor

Code snippet

curl --data '{"text_list": ["Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."]}' \
-H "Authorization:Token [YOUR_TOKEN_HERE]" \
-H "Content-Type: application/json" \
-D - \
https://api.monkeylearn.com/v2/extractors/ex_Y8EEfTKJ/extract/
from monkeylearn import MonkeyLearn

ml = MonkeyLearn('[YOUR_TOKEN_HERE]')
text_list = ["Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."]
module_id = 'ex_Y8EEfTKJ'
res = ml.extractors.extract(module_id, text_list)
print res.result
require 'monkeylearn'

Monkeylearn.configure do |c|
  c.token = '[YOUR_TOKEN_HERE]'
end

r = Monkeylearn.extractors.extract('ex_Y8EEfTKJ', ['Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California.'])
puts r.result
<?php

require 'autoload.php';

$ml = new MonkeyLearnClient('[YOUR_TOKEN_HERE]');
$text_list = ["Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."];
$module_id = 'ex_Y8EEfTKJ';
$res = $ml->extractors->extract($module_id, $text_list);
var_dump($res->result);

?>
var MonkeyLearn = require('monkeylearn');

var ml = new MonkeyLearn('[YOUR_TOKEN_HERE]');
var module_id = 'ex_Y8EEfTKJ';
var text_list = ["Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."];
var p = ml.extractors.extract(module_id, text_list);
p.then(function (res) {
    console.log(res.result);
});
import com.monkeylearn.MonkeyLearn;
import com.monkeylearn.MonkeyLearnResponse;
import com.monkeylearn.MonkeyLearnException;

public class App {
    public static void main( String[] args ) throws MonkeyLearnException {
        MonkeyLearn ml = new MonkeyLearn("[YOUR_TOKEN_HERE]");
        String moduleId = "ex_Y8EEfTKJ";
        String[] textList = {"Google is an American multinational technology company that specializes in Internet-related services and products. These include online advertising technologies, search, cloud computing, software, and hardware. Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."};
        MonkeyLearnResponse res = ml.extractors.extract(moduleId, textList);
        System.out.println( res.arrayResult );
    }
}

Example response body

{
  "result": [
    [
      {
        "sentence": "Google is an American multinational technology company that specializes in Internet-related services and products."
      },
      {
        "sentence": "These include online advertising technologies, search, cloud computing, software, and hardware."
      },
      {
        "sentence": "Google was founded in 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University, in California."
      }
    ]
  ]
}

Extracts the sentences from a given text.

HTTP Request

POST https://api.monkeylearn.com/v2/extractors/ex_Y8EEfTKJ/extract/

Parameters

This method doesn’t accept parameters.

Request body

Parameter Description
text_list A list of texts from which to extract the entities.

Response

Property Description
result A list that contains for each text, a list of the different entities extracted with their type.