how to make URL Shortener using Python and cutt.ly api

Free Python Code - Aug 12 '23 - - Dev Community

welcome everybody πŸ™‚πŸ–

Today I will share with you how to shorten a link using Python language and cutt.ly api
In an easy and simple way

step 1

you need to create an account in cutt.ly
create account from here

step 2

click on API and select "API key"

Image description

step 3

click on "manage API"

Image description

step 4

Generate api key

Image description

click on "OK"

Image description

step 5

Now you have api key you can use it to shorten links
copy this key

Image description

step 6

use the api key in this code with any link you want to shorten it


import requests

api_key = 'Your API Key'
url = 'https://www.flaticon.com/uicons/interface-icons'

r = requests.get(f'http://cutt.ly/api/api.php?key={api_key}&short={url}')
print(r.json())

Enter fullscreen mode Exit fullscreen mode

result

"""
{'url': {'status': 7, 'fullLink': 'https://www.flaticon.com/uicons/interface-icons',
'date': '2023-08-12', 'shortLink': 'https://cutt.ly/hwf2vorm',
'title': 'UIcons: 18,000+ Free icons, SVG and icon font. Awesome icons for any project'}}

"""

Now we're done πŸ€—

Don't forget to like and follow πŸ™‚
Support us on PayPal

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .