Getting Started

Introduction

NLP-API was developed to provide various NLP tools via a REST API.

To get started simply sign up and use your API token in any of the available API endpoints documented below for instant access.

If you have any questions or concerns, feel free to contact us.

Authentication

As mentioned above, when you sign up for free you will find your API token on your dashboard. Simply add this to any of our API endpoints as a GET or POST parameter to gain access. Examples of how this is done can be found below.

API Endpoints

Classification

Categorization

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/categorize HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/categorize HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to be categorized.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data > label The label of the category.
data > score The score/confidence of the associated label.
Supported languages
code full name
ar Arabic
de German
en English
es Spanish
fr French
it Italian
pt Portuguese
tr Turkish
zh Chinese

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/categorize?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/categorize' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                {
                    "label": "business",
                    "score": 0.8951839804649353
                },
                {
                    "label": "world",
                    "score": 0.03696263208985329
                },
                {
                    "label": "politics",
                    "score": 0.028095822781324387
                },
                {
                    "label": "tech",
                    "score": 0.009219390340149403
                },
                {
                    "label": "entertainment",
                    "score": 0.007675238884985447
                },
                {
                    "label": "health",
                    "score": 0.0055280327796936035
                },
                {
                    "label": "science",
                    "score": 0.004949952010065317
                },
                {
                    "label": "crime_and_law",
                    "score": 0.004148943815380335
                },
                {
                    "label": "environment",
                    "score": 0.0030002384446561337
                },
                {
                    "label": "education",
                    "score": 0.002320232568308711
                },
                {
                    "label": "disasters_and_accidents",
                    "score": 0.0015238006599247456
                },
                {
                    "label": "sport",
                    "score": 0.001391716068610549
                }
            ]
        }
        
            
        

Topic Tagging

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/topics HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/topics HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to get topics for.

Response Objects

name description
data An array of strings of topics related to the text.
Supported languages

The topic tagging API is multi-lingual.

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/topics?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/topics' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                "World Bank",
                "Joe Biden",
                "Biden"
            ]
        }
        
            
        

Named Entity Recognition (NER)

NER

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/ner HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/ner HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to get entities for.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data > text The entity.
data > start_char The index of the entities first character within the string.
data > end_char The index of the entities last character within the string.
data > label The type of entity identified.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/ner?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/ner' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                {
                    "text": "US",
                    "start_char": 0,
                    "end_char": 2,
                    "label": "GPE"
                },
                {
                    "text": "Joe Biden",
                    "start_char": 13,
                    "end_char": 22,
                    "label": "PERSON"
                },
                {
                    "text": "Indian-American",
                    "start_char": 33,
                    "end_char": 48,
                    "label": "NORP"
                },
                {
                    "text": "Ajay Banga",
                    "start_char": 61,
                    "end_char": 71,
                    "label": "PERSON"
                },
                {
                    "text": "US",
                    "start_char": 79,
                    "end_char": 81,
                    "label": "GPE"
                },
                {
                    "text": "the World Bank",
                    "start_char": 95,
                    "end_char": 109,
                    "label": "ORG"
                }
            ]
        }
        
            
        

NER Visualization

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/ner/visualize HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/ner/visualize HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to get entities for.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

This endpoint returns HTML of the text with entities highlighted within.

Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/ner/visualize?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/ner/visualize' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response (HTML processed)

US GPE President Joe Biden PERSON has named Indian-American NORP businessman Ajay Banga PERSON as the US GPE pick to lead the World Bank ORG .

NER Labels

Endpoints

            
                GET https://api.nlp-api.com/v1/ner/labels HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
language true Specify a supported NER language.

Response Objects

name description
data > label The type of entity.
data > description A description of the label.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/ner/labels?language=en&api_token=YOUR_API_TOKEN
            
        

Example Response

            
                
        {
            "data": [
                {
                    "label": "CARDINAL",
                    "description": "Numerals that do not fall under another type"
                },
                {
                    "label": "DATE",
                    "description": "Absolute or relative dates or periods"
                },
                {
                    "label": "EVENT",
                    "description": "Named hurricanes, battles, wars, sports events, etc."
                },
                {
                    "label": "FAC",
                    "description": "Buildings, airports, highways, bridges, etc."
                },
                {
                    "label": "GPE",
                    "description": "Countries, cities, states"
                },
                {
                    "label": "LANGUAGE",
                    "description": "Any named language"
                },
                {
                    "label": "LAW",
                    "description": "Named documents made into laws."
                },
                {
                    "label": "LOC",
                    "description": "Non-GPE locations, mountain ranges, bodies of water"
                },
                ...
            ]
        }
        
            
        

Disambiguation

Part-of-Speech (POS) Tagging

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/pos HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/pos HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to get entities for.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data > text The entity.
data > start_char The index of the entities first character within the string.
data > end_char The index of the entities last character within the string.
data > label The type of entity identified.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/pos?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/pos' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                {
                    "text": "US",
                    "position": "PROPN",
                    "tag": "NNP",
                    "dep": "compound",
                    "shape": "XX",
                    "is_alpha": true,
                    "is_stopword": true,
                    "type": "proper noun",
                    "description": "noun, proper singular"
                },
                {
                    "text": "President",
                    "position": "PROPN",
                    "tag": "NNP",
                    "dep": "compound",
                    "shape": "Xxxxx",
                    "is_alpha": true,
                    "is_stopword": false,
                    "type": "proper noun",
                    "description": "noun, proper singular"
                },
                {
                    "text": "Joe",
                    "position": "PROPN",
                    "tag": "NNP",
                    "dep": "compound",
                    "shape": "Xxx",
                    "is_alpha": true,
                    "is_stopword": false,
                    "type": "proper noun",
                    "description": "noun, proper singular"
                },
                {
                    "text": "Biden",
                    "position": "PROPN",
                    "tag": "NNP",
                    "dep": "nsubj",
                    "shape": "Xxxxx",
                    "is_alpha": true,
                    "is_stopword": false,
                    "type": "proper noun",
                    "description": "noun, proper singular"
                },
                {
                    "text": "has",
                    "position": "AUX",
                    "tag": "VBZ",
                    "dep": "aux",
                    "shape": "xxx",
                    "is_alpha": true,
                    "is_stopword": true,
                    "type": "auxiliary",
                    "description": "verb, 3rd person singular present"
                },
                ...
            ]
        }
        
            
        

Dependency Parser

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/dependency/parse HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/dependency/parse HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to process.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data > text The original token text.
data > dependency The syntactic relation connecting child to head.
data > text_head The original text of the token head.
data > head_position The part-of-speech tag of the token head.
data > children An array of the immediate syntactic dependents of the token.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/dependency/parse?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/dependency/parse' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                {
                    "text": "US",
                    "dependency": "compound",
                    "text_head": "President",
                    "head_position": "PROPN",
                    "children": []
                },
                {
                    "text": "President",
                    "dependency": "compound",
                    "text_head": "Biden",
                    "head_position": "PROPN",
                    "children": [
                        "US"
                    ]
                },
                {
                    "text": "Joe",
                    "dependency": "compound",
                    "text_head": "Biden",
                    "head_position": "PROPN",
                    "children": []
                },
                {
                    "text": "Biden",
                    "dependency": "nsubj",
                    "text_head": "named",
                    "head_position": "VERB",
                    "children": [
                        "President",
                        "Joe"
                    ]
                },
                {
                    "text": "has",
                    "dependency": "aux",
                    "text_head": "named",
                    "head_position": "VERB",
                    "children": []
                },
                {
                    "text": "named",
                    "dependency": "ROOT",
                    "text_head": "named",
                    "head_position": "VERB",
                    "children": [
                        "Biden",
                        "has",
                        "Banga",
                        "pick",
                        "."
                    ]
                },
                ...
            ]
        }
        
            
        

Dependency Visualization

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/dependency/visualize HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/dependency/visualize HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to process.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

This endpoint returns an SVG of the dependencies visualized..

Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/dependency/visualize?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/dependency/visualize' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Noun Chunks

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/dependency/noun-chunks HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/dependency/noun-chunks HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to process.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data > text The original token text.
data > text_root The original text of the word connecting the noun chunk to the rest of the parse.
data > dependency_root Dependency relation connecting the root to its head.
data > text_root_head The text of the root token’s head.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/dependency/noun-chunks?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/dependency/noun-chunks' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                {
                    "text": "US President Joe Biden",
                    "text_root": "Biden",
                    "dependency_root": "nsubj",
                    "text_root_head": "named"
                },
                {
                    "text": "Indian-American businessman Ajay Banga",
                    "text_root": "Banga",
                    "dependency_root": "dobj",
                    "text_root_head": "named"
                },
                {
                    "text": "the US",
                    "text_root": "US",
                    "dependency_root": "nsubj",
                    "text_root_head": "pick"
                },
                {
                    "text": "the World Bank",
                    "text_root": "Bank",
                    "dependency_root": "dobj",
                    "text_root_head": "lead"
                }
            ]
        }
        
            
        

Misc

Sentiment Analysis

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/sentiment HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/sentiment HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to analyze.

Response Objects

name description
data > label The label of the sentiment category (positive/neutral/negative).
data > score The score/confidence of the associated label.
Supported languages

The sentiment analysis API is multi-lingual, but has been fine-tuned on the 8 languages below.

code full name
ar Arabic
en English
fr French
de German
hi Hindi
it Italian
es Spanish
pt Portuguese

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/sentiment?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/sentiment' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                [
                    {
                        "label": "negative",
                        "score": 0.05799861252307892
                    },
                    {
                        "label": "neutral",
                        "score": 0.5485581755638123
                    },
                    {
                        "label": "positive",
                        "score": 0.39344319701194763
                    }
                ]
            ]
        }
        
            
        

Language Detection

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/language/detect HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/language/detect HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to detect the language for.

Response Objects

name description
data > language The language with the top score.
data > scores The score/confidence of each language as a key-value pair.
Supported languages

This endpoint supports over 100 languages. Run the example to see the full list of supported languages.

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/language/detect?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/language/detect' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": {
                "language": "en",
                "scores": {
                    "en": 0.41351402939492266,
                    "ch": 0.38845199465546865,
                    "jv": 0.3882611185340714,
                    "id": 0.3700324489406376,
                    "es": 0.3652605459057072,
                    "ms-Latn": 0.36407711395304443,
                    "oc": 0.35695743462492846,
                    "ia": 0.35688108417636955,
                    "la": 0.3507157854552395,
                    "bi": 0.34636380988738313,
                    "io": 0.3442641725520137,
                    "eu": 0.3423172361137622,
                    "pt-PT": 0.34197365909524724,
                    "pt-BR": 0.3408856652032831,
                    "ca": 0.33827066234014125,
                    "eo": 0.3355602214163008,
                    "gl": 0.33517846917350635,
                    "af": 0.334796716930712,
                    "br": 0.3343004390150792,
                    "et": 0.3338232487115862,
                    "it": 0.3338232487115862,
                    "fy": 0.3327161672074823,
                    "cy": 0.3274098110326398,
                    "hu": 0.3273143729719412,
                    "sv": 0.32607367818285937,
                    "nb": 0.32571101355220466,
                    "nn": 0.3254056117579691,
                    "tr": 0.3248520710059172,
                    "gd": 0.32160717694216456,
                    "nl": 0.32153082649360565,
                    "de": 0.31624355793090286,
                    "sq": 0.31490742508112235,
                    "da": 0.31397213208627606,
                    "lv": 0.31376216835273907,
                    "sw": 0.31343767894636376,
                    "sl": 0.31246421072723807,
                    "fr": 0.3121588089330025,
                    "ug-Latn": 0.3117197938537889,
                    "tl": 0.3111089902653178,
                    "ku": 0.30990647070051536,
                    "ga": 0.3097728574155373,
                    ...
                }
            }
        }
        
            
        

Sentence Segmentation

Endpoints

GET endpoint can be used for short texts only (usually less than 250 words). Text must be URL-encoded when using GET.

            
                GET https://api.nlp-api.com/v1/sentence/segments HTTP/1.1
            
        

POST endpoint can be used for long text.

            
                POST https://api.nlp-api.com/v1/sentence/segments HTTP/1.1
            
        

HTTP GET/POST Parameters

name required description
api_token true Your API token which can be found on your account dashboard.
text true Text you want to process.
language false Specify a language if you know it. If this is omitted we automatically detect the language.

Response Objects

name description
data An array of sentences extracted from the text.
Supported languages
code full name
ca Catalan
zh Chinese
hr Croatian
da Danish
nl Dutch
en English
fi Finnish
fr French
de German
el Greek
it Italian
ja Japanese
ko Korean
lt Lithuanian
mk Macedonian
nb Norwegian Bokmål
pl Polish
pt Portuguese
ro Romanian
ru Russian
es Spanish
sv Swedish
uk Ukrainian

Example Request (HTTP GET)

            
                GET https://api.nlp-api.com/v1/sentence/segments?text=US%20President%20Joe%20Biden%20has%20named%20Indian-American%20businessman%20Ajay%20Banga%20as%20the%20US%20pick%20to%20lead%20the%20World%20Bank.&api_token=YOUR_API_TOKEN
            
        

Example Request (cURL POST)

            
curl --location --request POST 'https://api.nlp-api.com/v1/sentence/segments' \
--header 'Content-Type: application/json' \
--data-raw '{
    "api_token": "YOUR_API_TOKEN",
    "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank."
}'
            
        

Example Response

            
                
        {
            "data": [
                "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.",
                "The move comes as the US increases pressure on the bank to put more emphasis on tackling climate change.",
                "Mr Banga led credit card giant Mastercard for more than a decade and now works in private equity.",
                "US officials said he had the experience to help the bank work with the private sector towards its goals.",
                "It is up to the bank's board to officially appoint its next head.",
                "On Wednesday, the bank said it planned to interview a shortlist of up to three candidates and aimed to name a new leader by early May.",
                "It said female nominees were strongly encouraged.",
                "It is not clear if other countries will put forward other suggestions.",
                "The US, the World Bank's biggest shareholder, has traditionally been in charge of selecting the person to lead the institution, which lends billions of dollars to countries each year.",
                "Treasury Secretary Janet Yellen said she wanted to see the World Bank serve as a \"force multiplier for good by setting the right agenda\".",
                "She said Mr Banga was \"uniquely\" equipped to take on that charge, pointing to his track record of forging partnerships between governments, companies and non-profits.",
                "Now a US citizen, Mr Banga started his career in his native India, where his father was an officer in the army.",
                "He worked at Nestle and Citigroup before joining Mastercard.",
                "Mr Banga retired from the firm in 2021 and now serves as a vice chairman at General Atlantic, a private equity firm, where he sits on the advisory board of its $3.5bn climate fund.",
                "He has also worked with the White House as co-chair of the Partnership for Central America, an initiative aimed at increasing private sector investment in the area, to try to stem the flow of migrants to the US.",
                "Mr Banga's decades in business might help inspire confidence in the bank in Congress, including from Republicans, who often criticise international organisations, said Amanda Glassman, executive vice president at the Center for Global Development.",
                "But she said it remained to be seen whether he was the right pick, noting that he had less experience with the government and development work that is core to the bank's job.",
                "\"We're looking forward to hearing his vision of what the bank should be,\" she said.",
                "Whoever becomes the bank's next leader will face the challenge of trying to balance the immediate financial needs of low-income countries, many of them facing debt crises, while shifting to tackle issues such as climate change, global conflict and pandemic risks - all without any clear additional money on the table.",
                "\"There is a lot riding on this next phase of the World Bank's strategy,\" Ms Glassman said.",
                "\"It's a moment when the World Bank can either step up to be really relevant or be marginalised and not important.\"",
                "While there is general consensus that the bank needs to evolve, \"there is less agreement on how, and there's a worry about the balancing act that needs to be done,\" she added.",
                "If confirmed, Mr Banga would replace David Malpass, who was nominated by former US President Donald Trump and said this month he would step down from the post by June, nearly a year before his five-year term was set to end.",
                "He had been criticised by environmental advocates for being slow to direct the bank's resources to address climate change.",
                "Last year, he was publicly rebuked by the White House after he said he did not know if fossil fuels were driving climate change, remarks for which he later apologised."
            ]
        }
        
            
        

Errors

Errors

If your request was unsuccessful, you will receive a JSON formatted error. Below you will find the potential errors you may encounter when using the API.

Errors

error code HTTP status description
malformed_parameters 400 Validation of parameters failed. The failed parameters are usually shown in the error message.
unsupported_language 400 The language provided via the language parameter or the automatically detected language is not supported. The failed language is usually shown in the error message.
word_count_limit 400 The number of words in the text exceeds your plan allowance. The number of words is usually shown in the error message.
invalid_api_token 401 Invalid API token.
usage_limit_reached 402 Usage limit of your plan has been reached. Usage limit and remaining requests can be found on the X-UsageLimit-Limit header.
endpoint_access_restricted 403 Access to the endpoint is not available on your current subscription plan.
resource_not_found 404 Resource could not be found.
invalid_api_endpoint 404 API route does not exist.
rate_limit_reached 429 Too many requests in the past 60 seconds. Rate limit and remaining requests can be found on the X-RateLimit-Limit header.
server_error 500 A server error occured.
maintenance_mode 503 The service is currently under maintenance.

Example Error Response

            
                
            {
                "error": {
                    "code": "malformed_parameters",
                    "message": "The published_before parameter(s) are incorrectly formatted."
                }
            }
        
            
        

Examples

Code Examples

See our prepared examples below to quickly get started implementing our API into your next project.

PHP

    
        $curl = curl_init();

        curl_setopt_array($curl, array(
          CURLOPT_URL => 'https://api.nlp-api.com/v1/categorize',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_POSTFIELDS =>'{
            "api_token": "YOUR_API_TOKEN",
            "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.",
            "language": null
        }',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        echo $response;
    

Python

    
        import http.client

        conn = http.client.HTTPSConnection("api.nlp-api.com")
        payload = "{\r\n    \"api_token\": \"YOUR_API_TOKEN\",\r\n    \"text\": \"US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.\",\r\n    \"language\": null\r\n}"
        headers = {
          'Content-Type': 'application/json'
        }
        conn.request("POST", "/v1/categorize", payload, headers)
        res = conn.getresponse()
        data = res.read()
        print(data.decode("utf-8"))
    

Go

    
        package main

        import (
          "fmt"
          "strings"
          "net/http"
          "io/ioutil"
        )

        func main() {

          url := "https://api.nlp-api.com/v1/categorize"
          method := "POST"

          payload := strings.NewReader(`{`+"
        "+`
            "api_token": "YOUR_API_TOKEN",`+"
        "+`
            "text": "US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank..",`+"
        "+`
            "language": null`+"
        "+`
        }`)

          client := &http.Client {
          }
          req, err := http.NewRequest(method, url, payload)

          if err != nil {
            fmt.Println(err)
            return
          }
          req.Header.Add("Content-Type", "application/json")

          res, err := client.Do(req)
          if err != nil {
            fmt.Println(err)
            return
          }
          defer res.Body.Close()

          body, err := ioutil.ReadAll(res.Body)
          if err != nil {
            fmt.Println(err)
            return
          }
          fmt.Println(string(body))
        }
    

JavaScript

    
        var data = JSON.stringify({"api_token":"YOUR_API_TOKEN","text":"US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.","language":null});

        var xhr = new XMLHttpRequest();
        xhr.withCredentials = true;

        xhr.addEventListener("readystatechange", function() {
          if(this.readyState === 4) {
            console.log(this.responseText);
          }
        });

        xhr.open("POST", "https://api.nlp-api.com/v1/categorize");
        xhr.setRequestHeader("Content-Type", "application/json");

        xhr.send(data);
    

C#

    
        var client = new RestClient("https://api.nlp-api.com/v1/categorize");
        client.Timeout = -1;
        var request = new RestRequest(Method.POST);
        request.AddHeader("Content-Type", "application/json");
        request.AddParameter("application/json", "{\r\n    \"api_token\": \"YOUR_API_TOKEN\",\r\n    \"text\": \"US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.\",\r\n    \"language\": null\r\n}",  ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);
        Console.WriteLine(response.Content);
    

Java

    
        OkHttpClient client = new OkHttpClient().newBuilder().build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\r\n    \"api_token\": \"YOUR_API_TOKEN\",\r\n    \"text\": \"US President Joe Biden has named Indian-American businessman Ajay Banga as the US pick to lead the World Bank.\",\r\n    \"language\": null\r\n}");
        Request request = new Request.Builder()
          .url("https://api.nlp-api.com/v1/categorize")
          .method("POST", body)
          .addHeader("Content-Type", "application/json")
          .build();
        Response response = client.newCall(request).execute();