How to fully validate a URL in Javascript

Today we are going to review how to use one of our APIs to fully validate URLs. This functions on multiple levels: checking syntax, existence, endpoint, and security. All of this can be achieved in just two simple steps. Here we go.

Installation comes first, requiring this script tag to be placed in your HTML file.

<script src=""></script>

Now we can move on to calling our URL validation function.

var CloudmersiveValidateApiClient = require('cloudmersive-validate-api-client');var defaultClient = CloudmersiveValidateApiClient.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 CloudmersiveValidateApiClient.DomainApi();var request = new CloudmersiveValidateApiClient.ValidateUrlRequestFull(); // ValidateUrlRequestFull | Input URL requestvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.domainUrlFull(request, callback);

And you’re done! You can test it out by entering in a URL to try, but that’s about all there is to it. For more like this, you may wish to look at our documentation section for a full list of validation functions available.

Written by

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

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