Simply - URL Shortener

Simply - URL Shortener

Anish

Simply API Documentation

Welcome to the Simply URL Shortener API! This API allows you to shorten long URLs and provides a mechanism to redirect users to the original URL.You can also see how many times the shortened link has been clicked. Follow the documentation to integrate this service into your applications.

Base URL: https://sl8.vercel.app

Shorten URL Endpoint

Endpoint

POST /api/url/shorten

This endpoint is used to shorten a long URL.

Request

Request Body :
{
  "longUrl": "https://example.com/your-veryyy-longggggg-urllllll"
}
Success Response :
{
  "shortUrl": "https://sl8.vercel.app/shorty",
  "clickCount":7
}

Error Responses :

{
  "error": "Invalid input. Please provide a valid longUrl."
}
{
  "error": "Internal server error. Please try again later."
}

Example :

Request :

curl -X POST -H "Content-Type: application/json" -d '{"longUrl": "https://example.com/your-long-url"}' https://sl8.vercel.app/api/url/shorten

in Node.js:

const axios = require('axios');

const shortenUrl = async (longUrl) => {
  try {
    const url = 'https://sl8.vercel.app/api/url/shorten';
    const response = await axios.post(url, { longUrl }, { withCredentials: true, crossDomain: true });
    console.log('Shortened URL:', response.data.shortUrl);
    console.log('Click Count:', response.data.clickCount);
  } catch (error) {
    console.error('Error shortening URL:', error.message);
  }
};

// Example Usage
const exampleLongUrl = 'https://example.com/yourrr-longgg-url';

shortenUrl(exampleLongUrl);

Response :

in Json Format:

{
  "shortUrl":"https://sl8.vercel.app/Something",
  "clickCount":1
}

See it in Action :

Simply Screenshot

Share this article