/URL-Shortener-API

A url shortening API created using node.js

Primary LanguageHTML

URL Shortening API

This shortens a link and returns it as a JSON object. Follow the steps below to use the API.

Pre-Requisites

~ include the below JQUERY library in your header:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

To get a shortened URL:

~ Send a post request to urlq.herokuapp.com url:'/getlink' having JSON data as follows:
~ {link : theLinkToBeShortened}
~ Example:
$.ajax({
type: "POST",
url: "urlq.herokuapp.com/getlink",
data: {url: theUrlToBeShortened}, // URL
dataType: "json", // indicates response is in JSON format
success: function (response) {
// The shortened URL is response.shortenedURL
}
});

To access the original URL:

~ To use the URL just perform a GET request to urlq.herokuapp.com and the original URL will be redirected.
~ Example:
urlq.herokuapp.com/353 => this will get redirected to the original URL