URL shortener using python

In this article, we shall see how to create a TinyURL link for our long URLs. This can be performed using a python library called pyshorteners which is a python wrapper built around the TinyURL website. With the help of this library, we can get a shortened URL for our app with just three lines of code.

What is tinyurl?

TinyURL is a URL shortening web service, which provides short aliases for redirection of long URLs. 

For example this


can be converted to


this with the help pf tinyURL.


The library can be easily installed using pip as

pip install pyshorteners


This is a sample example to generate a short url.

url shortener

The output of the above code snippet is,



That is it. We have generated our shortened URL with the help of this library in 3 lines of code. Hope this article was helpful.

Happy coding!