How to build shortlinks with python on Mac — TinyUrls make your long url shorter.

Here’s a quick tutorial on how to build shortlinks with python on Mac. Also, you could consider this a how to make tinylinks using python 2.7. This all started because I was learning about web scraping.

BTW: Don’t split because this says a language you haven’t head of before…

Image for post
Image for post
This is all it takes two build a tinyurl.

Making Tinyurl’s in an automated environment — Python!

Making Tinyurl’s in an automated environment is easy if you use python, below I’m going to link you around, and show you how you can start using python for free, no funnel, no sign-ups, and you get to make a link like this: Test it for yourself, it will drive you to my personal domain,

So, check this out… Trying to learn python from scratch is a lot of fun, appears to be a bit of a ramp up to being decent too, but that’s why I’m blogging about it every day. Learning how to install python seems to be critical for the future of my career…

You might be thinking, “tyler im going to make shit loads of the same tinyurl for my service page and rank it to the f#$cken moon.

Image for post
Image for post
Nope… You can’t make a short URL of a short URL, I tried. Good thinking though.
Image for post
Image for post
You can’t make more than 1 per link… unless you redirect it, okay just leave this part and learn how below.

You get one tinyURL per unique URL. To learn more about other shortlink services, here’s a top 5 list.

Making Tinylinks with python 2.7, easy peezy.

After playing around with python, I ran across something interesting, and if you know about SEO, you know that putting links on keywords you want to rank for, like my name, Tyler Garrett… The link inside of the name, Tyler Garrett, is a Tiny url, from

Here’s the example. 2 lines of code, and you get a shortlink in return. Beautiful, I used to spin my wheels making short links. This is stupid easy.

5 lines of total code….

  1. install tinyurl pack with pip
  2. open python
  3. import tinyurl pack
  4. create a link
  5. copy paste new link
Image for post
Image for post

First we will want to make sure we install tinyurl’s pip.

python -m pip install tinyurl --user

Now, if you’re on a mac, your 2.7 python will the tiny url pip available.

Now you can turn on python.

Type python

Now you should see the 2.7 version start, you maybe wondering, why not version 3.7… Well, it didn’t work.

Image for post
Image for post

Alright, so that’s why I’m saying type python and not python3

With python running in your terminal, let’s start with the import.

import tinyurl


And poof.

Image for post
Image for post
mind blowing.

Now, if you’re like me, you’re probably thinking, time to make a bunch of short links, hehe. Shortlinks like this, count towards you increasing your domain ranking with Google. Google tracks short links towards SEO power.

Other shortlink services are,, and now consider legacy

I have access to (until april 2019), bitly and owly are free,…

….but now with this, I feel there’s no reason to use any other service unless it’s this easy. Excited to build another app to insert a list of links, and output a bunch of tinyurls.

Automation of tinyurls is easy with python, I’m in love.

Blogged again on linkedin.

Written by

Hello, I’m Tyler. I founded and helped 150+ companies solve problems, enjoy helping others, my writing is the same. I’m like chef ramsey in data

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store