Cloudmersive

Get a Canonical URL in Node.JS

If you are working with an HTML document and need to retrieve the canonical link, you don’t want to do a lot of comparison between documents and searching through HTML code to find it. By utilizing this simple API in Node.JS, you will be able to automatically get the rel=canonical URL of the HTML document — no hassle needed.

To kick off the operation, we can run this command to install the SDK:

npm install cloudmersive-convert-api-client --save

Or, we can add this snippet to our package.json:

"dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

With the installation out of the way, we can input our file or file URL and API key into the following code to call the function:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

To obtain your API key, visit the Cloudmersive website to register for a free account; this will provide 800 monthly calls across our multitude of APIs.

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