How to Spell Check a Word and get the results as a JSON in Node.JS
1 min readApr 9, 2020
Setting up a spell checker can definitely be a headache. Believe me, I know, I just wrote one out. Luckily for you, I’ve made it into a lovely API that can be used with just a few lines of code. Let me show you.
We begin by installing the NLP client with this reference for package.json.
"dependencies": {
"cloudmersive-nlp-api-client": "^1.1.2"
}
Now call spellCheckCheckJson:
var CloudmersiveNlpApiClient = require('cloudmersive-nlp-api-client');var defaultClient = CloudmersiveNlpApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveNlpApiClient.SpellCheckApi();var value = "value_example"; // String | Input sentencevar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.spellCheckCheckJson(value, callback);
Input a string to get your spell check results as a JSON file. It’s as simple as that. For more amazingly practical APIs like this one, spare a glance at the documentation section for the NLP client.