URL Shortening — How to Batch-Process 100 Long Links Offline
Do social media for any length of time and you'll notice everyone's FB and Instagram posts use short links — easier to click, easier to spread. Online generators are easy to find, but the drawbacks are obvious: 1. no batching; 2. the domain isn't yours.
The URL shortening market
Digging around, URL shortening turns out to be a genuinely interesting tool market, with Bitly the overseas leader. Free services for converting long URLs include (international services listed; domestic ones are a search away):

Popular tools:
- Bitly: the most popular service, supports custom links; registered users get click analytics. Visit Bitly
- TinyURL: create short links without registering; partial customization supported. Visit TinyURL
- Rebrandly: custom-domain short links for brands; free tier is limited. Visit Rebrandly
- Google's shortener: officially migrated to Firebase Dynamic Links — with a Firebase project you can create short links. Visit Firebase
- Ow.ly: Hootsuite's shortener, suited to social media management and click tracking. Visit Ow.ly
- Browser extensions: extensions like "Short URL" generate short links right in the browser.
All of them: paste the long link, click, get the short one.
Paid batch shortening with the Bitly API
Using the Bitly API — Python example. Register for a Bitly API Access Token, then install requests:
pip install requests
The code:
import requests
def shorten_url(long_url):
# your Bitly Access Token
access_token = "YOUR_BITLY_ACCESS_TOKEN"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
payload = {"long_url": long_url}
response = requests.post("https://api-ssl.bitly.com/v4/shorten", json=payload, headers=headers)
if response.status_code == 200:
return response.json().get("link")
else:
print("Error:", response.status_code, response.text)
return None
# usage
long_url = "https://www.yourwebsite.com/some/very/long/url"
short_url = shorten_url(long_url)
print("Short URL:", short_url)
Replace "YOUR_BITLY_ACCESS_TOKEN" with your token; short_url is the generated link.
Free batch shortening with pyshorteners
pyshorteners is a lightweight Python library supporting multiple shortening services:
pip install pyshorteners
Then:
import pyshorteners
def shorten_url(long_url):
s = pyshorteners.Shortener()
return s.tinyurl.short(long_url)
# usage
long_url = "https://www.yourwebsite.com/some/very/long/url"
print("Short URL:", shorten_url(long_url))
Bitly vs pyshorteners
Bitly API pros and cons
Pros:
- Analytics: click statistics — geography, device type — great for behavior analysis.
- Branding: premium tiers support custom domains for professional, branded links.
- Stability: a veteran service; highly reliable, rarely down.
Cons:
- API token: registration and key management add setup steps.
- Free-tier caps: monthly link limits; fine personally, pricey at scale.
- API dependency: heavy use requires rate-limit management.
Best for: users needing branded links and click analytics — especially heavy social promotion.
pyshorteners pros and cons
Pros:
- Instant: no account, no keys — install and go.
- Free and unlimited: TinyURL's free tier has no volume cap; friendly for personal use.
- Multiple backends: supports different providers (Is.gd, Bitly, etc.).
Cons:
- No analytics: no click or behavior data.
- Weak branding: default TinyURL domain; suited to throwaway links.
- Variable stability: TinyURL is decent, but free providers can have outages or frequent maintenance.
Best for: small personal projects, no tracking needed — temporary shares, personal shortcuts.
Comparison
| Method | Analytics | Branding | Setup barrier | Stability | Use case |
|---|---|---|---|---|---|
| Bitly API | Yes | Yes | Higher | High | Business, click analysis |
| pyshorteners (TinyURL) | No | No | Low | Decent | Personal, temporary links |
Recommendation:
- Need analytics and branded links: Bitly.
- Just need quick short links with zero friction:
pyshorteners.
Batch shortening from Excel
Batch work means Excel. Here's code that reads long links from column A and writes short links to column C (column B holds my IDs — adjust to taste).
Use pandas to read/write Excel and pyshorteners to generate.
Prerequisites
pip install pandas pyshorteners openpyxl
Code
Assuming your file is urls.xlsx with long URLs in column A:
import pandas as pd
import pyshorteners
def shorten_urls_in_excel(file_path):
# read the Excel file
df = pd.read_excel(file_path)
# init the shortener
shortener = pyshorteners.Shortener()
# walk column A, writing short links to a new column
df['Shortened URL'] = df.iloc[:, 0].apply(lambda x: shortener.tinyurl.short(x) if pd.notnull(x) else None)
# save back
df.to_excel(file_path, index=False)
# usage
shorten_urls_in_excel('urls.xlsx')
How it works
- Reads the Excel file into a
DataFrame. apply()walks column A, shortening each URL into a new"Shortened URL"column.- Saves the
DataFrameback to the same file.
Run it, and column C holds the short links.
Do offline-generated short links expire?
Yes — it depends on the API's settings. For long-term business use, a paid API is recommended to keep links alive and observable.
Any online generator recommendations?
They're all similar. In China, Chinaz has one.