How to Create a URL Shortener Using Python and Bitly
Bitly is a service that allows you to create shortened links that redirect to longer, more complex URLs. These shortened links are easier to remember, share, and track than the original long URLs.
You can shorten URLs on the Bitly website using your own account. Bitly also offers an API that allows you to shorten a URL from an application. This works by sending a request to Bitly to shorten the link, which Bitly will return to your application.
you may integrate the Bitly API into a simple Python script.
How to Generate an Access Token Using a Bitly Account
You will need an access token to use the Bitly API. If you don’t already have a Bitly account, create one to generate a new access token.
How to Request a Long URL From the User Using a Python Script
You can now use your access token in a Python script. If you are not familiar with Python, there are other projects you can make to enhance your Python knowledge. These include buildinga GUI calendaror aword jumble game.
Before using the API, the user will need to input the URL they would like to shorten. you’re able to use command-line arguments to input the link into the Python script. You can view the full example in thisGitHub repo.

How to Use the Bitly API to Shorten the URL
Once you have the URL in the Python script, use the API to send a request to Bitly to shorten the URL.
How to Test the New URL in the Browser
Run the Python script in the command line to generate a new shortened link. you could enter the new link in the web browser, and it will redirect to the longer, original link.
Creating Shortened Links Using Bitly
Now you understand how to shorten links in Python to easier, more memorable links. it’s possible to use your script to shorten any long links before sharing it with others. It is also important to take the steps necessary to ensure the link is safe.
Before clicking any suspicious link, use one of these link checkers to check that it doesn’t lead to malware or other security threats.

It saves me hours and keeps my sanity intact.
These plugins will make you wonder why you used Photoshop in the first place.

My iPhone does it all, but I still need my dumb phone.
Who asked for these upgrades?

Make sure you don’t miss these movies and shows before Netflix removes them.