ShrtCode

ShrtCode

URL Shorteners

Shrtco.de is a simple and easy-to-use URL shortener tool that allows users to shorten long URLs into shorter ones. The tool is free to use and requires no account registration or login. Users can simply copy and paste the long URL into the tool, and it generates a short and unique URL that can be easily shared with others. Additionally, Shrtco.de offers a dashboard where users can manage and track their shortened URLs, including the number of clicks and the date and time of the clicks. Overall, Shrtco.de is a useful tool for anyone who wants to shorten long URLs for easier sharing and tracking.

Visit API

📚 Documentation & Examples

Everything you need to integrate with ShrtCode

🚀 Quick Start Examples

ShrtCode Javascript Examplejavascript
// ShrtCode API Example
const response = await fetch('https://shrtco.de/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Intro to shrtco.de API

shrtco.de is a free to use URL shortening API that allows developers to shorten long URLs to a much shorter and manageable format. With a simple HTTP GET request, you can shorten any long URL using the shrtco.de API.

This document is an overview of the shrtco.de API and how to use it in JavaScript.

Getting started with shrtco.de API

To get started with the shrtco.de API, you will need an API key. It's very simple to get one - just visit the shrtco.de website and register for a free account.

Once you have an API key, you can start making HTTP GET requests to the shrtco.de API. The API will return a shortened URL in JSON format.

Here are some examples of shrtco.de API calls in JavaScript:

Example 1

async function shortenUrl(longUrl, apiKey) {
  const res = await fetch(
    `https://api.shrtco.de/v2/shorten?url=${longUrl}`,
    {
      headers: {
        'Content-Type': 'application/json',
        'apikey': apiKey,
      },
    }
  );

  if (!res.ok) {
    const {status, statusText} = res;
    throw new Error(`Error: ${status} ${statusText}`);
  }

  const data = await res.json();

  return data.result.short_link;
}

This function takes in a long URL and an API key and returns a shortened URL. Here's how you can use this function:

const apiKey = 'YOUR_API_KEY';
const longUrl = 'https://www.google.com/';

const shortUrl = await shortenUrl(longUrl, apiKey);

console.log(shortUrl);  // 'https://shrtco.de/abc123'

Example 2

async function shortenUrls(longUrls, apiKey) {
  const urls = longUrls.map((url) => `url=${encodeURIComponent(url)}`);
  const query = urls.join('&');

  const res = await fetch(
    `https://api.shrtco.de/v2/shorten?${query}`,
    {
      headers: {
        'Content-Type': 'application/json',
        'apikey': apiKey,
      },
    }
  );

  if (!res.ok) {
    const {status, statusText} = res;
    throw new Error(`Error: ${status} ${statusText}`);
  }

  const data = await res.json();

  return data.result.map(({original_link, short_link}) => ({
    original_link,
    short_link,
  }));
}

This function takes in an array of long URLs and an API key and returns an array of objects that contain the original URL and the shortened URL.

const apiKey = 'YOUR_API_KEY';
const longUrls = [
  'https://www.google.com/',
  'https://www.amazon.com/',
  'https://www.github.com/',
];

const shortUrls = await shortenUrls(longUrls, apiKey);

console.log(shortUrls);
/*
[
  {original_link: 'https://www.google.com/', short_link: 'https://shrtco.de/abc123'},
  {original_link: 'https://www.amazon.com/', short_link: 'https://shrtco.de/def456'},
  {original_link: 'https://www.github.com/', short_link: 'https://shrtco.de/ghi789'},
]
*/

Conclusion

In this blog post, we've covered how to use the shrtco.de API to generate shortened URLs using JavaScript. The API is simple to use, and you can get started with it in just a few minutes. If you're building an application that requires URL shortening, give the shrtco.de API a try!

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jul 3Jul 5Jul 7Jul 9Jul 11Jul 13Jul 15Jul 17Jul 19Jul 21Jul 23Jul 25Jul 27Jul 29Aug 104008001440Minutes
Online
Offline

Related APIs in URL Shorteners