How to Part-of-Speech Tag a String in Node.js

All languages are made up of multiple ‘parts of speech’ which come together to form coherent sentences. For a computer to make meaning out of something as relatively abstract as human language, it needs to be able to identify words within a sentence based on which part-of-speech that word is occupying, rather than simply recognize the word itself. Our POS-Tagger API is equipped to automatically break down each word in an input sentence and identify its part of speech, returning a JSON with clearly defined data points that can be applied in a variety of linguistic/statistical directions.

Below, we’ll walk through how you can take advantage of this API easily using ready-to-run Node.js code snippets to structure your API call. To use this API, however, you’ll need a Cloudmersive API key — if you don’t have one, you can easily get one by registering a free account on our website.

Let’s first install the Node.js SDK:

npm install cloudmersive-nlp-api-client --save

Now let’s call the API. Include your API key in the second snippet where indicated:

var CloudmersiveNlpApiClient = require('cloudmersive-nlp-api-client');
var defaultClient = CloudmersiveNlpApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveNlpApiClient.PosTaggerApi();var request = new CloudmersiveNlpApiClient.PosRequest(); // PosRequest | Input stringvar callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.posTaggerTagSentence(request, callback);

Now all you need to do is configure your inputs, and you’re all set.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.