Link Shortener

API Usage Examples
cURL
curl -X POST \
https://api.frwrd.ing/shorten \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'url=https://www.google.com'

The server responds with: {"shortUrl":"https://frwrd.ing/lqywv6P"}

Node.js
const axios = require('axios');
const qs = require('qs');

axios.post('https://api.frwrd.ing/shorten', qs.stringify({ url: 'https://www.google.com' }), {
    headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
    }
})
.then((response) => {
    console.log('Shortened URL:', response.data.shortUrl);
})
.catch((error) => {
    console.error('Error:', error.response.data);
});                
Python
import requests

data = {
    'url': 'https://www.google.com'
}

response = requests.post('https://api.frwrd.ing/shorten', data=data, headers={
    'Content-Type': 'application/x-www-form-urlencoded'
})

if response.status_code == 200:
    print('Shortened URL:', response.json()['shortUrl'])
else:
    print('Error:', response.json()['error'])                
PHP
<?php
$url = 'https://api.frwrd.ing/shorten';
$data = array('url' => 'https://www.google.com');
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data),
    )
);

$context = stream_context_create($options);
$response = file_get_contents($url, false, the_context);

if ($response === FALSE) {
    echo 'Error: Could not connect to the server or server returned an error.';
} else {
    $decoded = json_decode($response, true);
    if (isset($decoded['shortUrl'])) {
        echo 'Shortened URL: ' . $decoded['shortUrl'];
    } else if (isset($decoded['error'])) {
        echo 'Error: ' . $decoded['error'];
    } else {
        echo 'Error: Unexpected server response.';
    }
}
?>                
Self-Host

frwrd.ing is powered by samestrin/url-shortening-api-vercel, a serverless application that provides URL shortening functionalities.

Using Vercel infrastructure - Vercel Functions, Vercel KV (Redis), and Vercel Postgres, this application offers a high performance, efficient and scalable solution for creating, serving, and tracking short URLs that redirect to the original, longer URLs.

If you'd like to host your own URL shortening service, then follow installation directions found in the README.md file.