Registry / http-networking / pyshorteners

pyshorteners

JSON →
library1.0.1pypypi✓ verified 86d ago

A Python library that wraps and consumes the most popular URL shortener APIs, including TinyURL, Bitly, and others. Current version 1.0.1, released in 2021; development appears stalled but library is functional. Supports Python 3.6+.

pip install pyshorteners
INSTALL
IMPORT
SIG · PYSHORTENERS
P
pyshorteners
http-networkingpythonv1.0.1
Install
3.5s avg
Import
30ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.030s · 22.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.5s · import 0.030s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Shortener
import pyshorteners s = pyshorteners.Shortener()
from pyshorteners import Shortener
Shortener is a class inside the module, not a direct import. Import pyshorteners then instantiate pyshorteners.Shortener().

Quickstart: import pyshorteners, create Shortener instance, call a provider's .short() method.

import pyshorteners s = pyshorteners.Shortener() # For services requiring API keys, set them via env or kwargs # short_url = s.tinyurl.short('https://www.example.com') # print(short_url) # Example with valid URL long_url = 'https://www.example.com' short_url = s.tinyurl.short(long_url) print(short_url)
Debug
Known issues
breakingVersion 1.0.0 removed the old Shortener class pattern. The new API uses pyshorteners.Shortener() and provider-specific methods (e.g., .tinyurl.short()). No more global short() function.
fix
Update imports: replace 'from pyshorteners import Shortener' with 'import pyshorteners' and use pyshorteners.Shortener().tinyurl.short(url).
affects: >=1.0.0,<2.0.0
deprecatedSome providers like Google URL Shortener (goo.gl) are deprecated or shut down. Using them will raise errors.
fix
Switch to active services like TinyURL (no API key) or Bitly (requires API key).
affects: >=1.0.0
gotchaMany providers (Bitly) require an API key. If not set, they silently fail or raise an error. Always check provider docs.
fix
Set API keys via environment variable or pass to Shortener constructor: pyshorteners.Shortener(bitly_token=os.environ.get('BITLY_TOKEN')).
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyshorteners'
Library not installed.
fix
Run: pip install pyshorteners
AttributeError: module 'pyshorteners' has no attribute 'Shortener'
Incorrect import pattern (e.g., from pyshorteners import Shortener). The correct import is 'import pyshorteners'.
fix
Replace 'from pyshorteners import Shortener' with 'import pyshorteners' and use pyshorteners.Shortener().
Upgrade
Version history
1.0.1latest on PyPI · released Mar 19, 2020
Audit
Dependencies
requestsrequiredHTTP client for API calls
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
pyshorteners — pip install pyshorteners · libregistry