Classification

Classify (POST)

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

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

Payload:

This endpoint expects a JSON in the request body (or payload body). It must be an object with the text_list property and a list of the texts you want to classify as value. For example:

GET Parameters:

  • sandbox (Optional): Set this parameter to 1 if you want to use the sandbox to perform the classification.
  • debug (Optional): Set this parameter to 1 if you want to use the debug output.

Response:

  • 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.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response body:

Multilabel Classify (POST)

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. In order for this endpoint to work, the module has to be set as a Multilabel Module.

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

Payload:

This endpoint expects a JSON in the request body (or payload body). It must be an object with the text_list property and a list of the texts you want to classify as value. For example:

GET Parameters:

  • sandbox (Optional): Set this parameter to 1 if you want to use the sandbox to perform the classification. It only works with custom modules.
  • debug (Optional): Set this parameter to 1 if you want to use the debug output.

Response:

  • 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.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

List Classifiers(GET)

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

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

Parameters: This method doesn’t accept parameters.

Response:

  • result: A list of dictionaries that contain the information about all your classifiers.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Classifier detail (GET)

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

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

Parameters: This method doesn’t accept parameters.

Response:

  • result: A dictionary that contains the classifier information and the sandbox categories.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Create Category on a Classifier (POST)

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

Endpoint: https://api.monkeylearn.com/v2/classifiers/<PROJECT_ID>/categories/

Parameters:

This endpoint expects a JSON in the request body (or payload body). You need to specify the category name and the id of the parent category. You can get the ids of all the current categories using the “Classifier Detail” endpoint.

Request body sample:

Edit category on a Classifier (PATCH)

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

Endpoint: https://api.monkeylearn.com/v2/classifiers/<PROJECT_ID>/categories/<CATEGORY_ID>/

Parameters:

This endpoint expects a JSON in the request body (or payload body). You can set the “parent_id” in order to change the parent of the category and you can also change name of the category using the “name” parameter.

Request body sample:

Delete category on a Classifier (DELETE)

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

Endpoint: https://api.monkeylearn.com/v2/classifiers/<PROJECT_ID>/categories/<CATEGORY_ID>/

Parameters:

This endpoint expects a JSON in the request body (or payload body). You can choose what to do with the samples of the category that is being deleted using the “samples-strategy” parameter. The “samples-strategy” parameter can have 2 values: “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.

Request body sample:

Upload samples to category (POST)

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

Endpoint: https://api.monkeylearn.com/v2/classifiers/[project_id]/samples/

Payload:

This endpoint expects a JSON in the request body (or payload body). It must be an object with the samples property with the value being a list of dictionaries with the sample text (text property) and the ID of the category that sample should be saved (category_id property). The category IDs can be retrived using the classifier detail endpoint.

Request body example:

Response:

  • result: An empty object.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Multilabel Upload samples to category (POST)

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

Endpoint: https://api.monkeylearn.com/v2/classifiers/[project_id]/samples/

Payload:

This endpoint expects a JSON in the request body (or payload body). It must be an object with the samples property with the value being a list of dictionaries with the sample text (text property) and the ID of the category that sample should be saved (category_id property), or a list of ids if the sample belongs to multiple categories. The category IDs can be retrived using the classifier detail endpoint.

Request body example:

Response:

  • result: An empty object.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Train Classifier (POST)

This endpoint allows you to train a classifier.

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

Parameters: This method doesn’t accept parameters.

Response:

  • result: An object with the job id of the training.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Deploy Classifier (POST)

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

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

Parameters: This method doesn’t accept parameters.

Response:

  • result: An empty object.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Create Classifier (POST)

This endpoint creates a new classifier.

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

Parameters:

This endpoint expects a JSON in the request body (or payload body). Only the name of the classifier is a mandatory field.

Request body sample:

Delete Classifier (DELETE)

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

To delete a classifier make a DELETE request to the following endpoint:

Endpoint: https://api.monkeylearn.com/v2/classifiers/<PROJECT_ID>/

Example request using curl:

Extraction

Keywords Extraction

Extract (POST)

Extract keywords from a list of texts in English.

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

Payload:

  • text_list: A list of texts from which to extract keywords.
  • max_keywords: The maximum amount of keywords to extract, defaults to 10.
  • use_stemming: Take words to their base form in order to get better results , defaults to 1 (true).
  • use_idfs: Use a language model for computing the Inverse Document Frequencies , defaults to 1 (true).
  • lowercase: Lowercase all the given text, defaults to 0 (false).
  • use_company_names: 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.’. Defaults to 0 (false).
  • expand_acronyms: Expand acronyms to they full form, for example ‘USA’ to ‘United States of America’ if both tokens appear in the given text. Defaults to 0 (false).
  • keep_ampersand: Keep the ‘&’ char when it appears inside a name. For example ‘Ferrara & Wolf’. Defaults to 0 (false).

Returns:

  • result: A list of the extracted keywords and their relevance.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Keywords Extraction (Spanish)

Extract (POST)

Extract keywords from a list of texts in Spanish.

Endpoint: https://api.monkeylearn.com/v2/extractors/ex_eV2dppYE/extract/

Payload:

  • text_list: A list of texts from which to extract keywords.
  • max_keywords: The maximum amount of keywords to extract (defaults to 10).

Response:

  • result: A list of the extracted keywords and their relevance.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Binary Document to Text Extractor

Extract (POST)

Extract plain text from binary documents as .doc, .docx, .pdf and .odt.

Endpoint: https://api.monkeylearn.com/v2/extractors/ex_8tMs2MDB/extract/

Payload:

  • file: The binary file from which to extract the text.

Response:

  • result: The extracted text.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Html to Text extractor

Extract (POST)

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.

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

Payload:

  • text_list: A list of htmls from which to extract the texts.

Returns:

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

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Entity Extractor

Extract (POST)

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.

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

Payload:

  • text_list: A list of texts from which to extract the entities.

Returns:

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

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Spanish Entity Extractor

Extract (POST)

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.

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

Payload:

  • text_list: A list of texts from which to extract the entities.

Response:

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

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response:

Pipelines

Run (POST)

Executes the selected pipeline.

Endpoint: https://api.monkeylearn.com/v2/pipelines/[pipeline_id]/run/

Parameters: Depends on the pipeline definition. The JSON you post here will be used as the initial state of the Pipeline.

Response:

  • result: A dictionary that contains the pipeline result.

Special headers returned:

  • 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.

Example request using curl:

Example response headers:

Example response: