Pygmy logo

Pygmy

Self-hosted URL shortener with analytics and custom links

Pygmy is an extensible, Python-based URL shortener with custom short codes, expiry options, secret protection, user dashboards, and built-in link analytics.

Pygmy banner

Overview

Powerful, Self-Hosted URL Shortening

Pygmy is a Python URL shortener designed for teams and individuals who want full control over their link infrastructure. Built with a loosely coupled architecture, it separates core shortening logic, a Flask-based REST API, and a Django UI layer, making it easy to integrate or extend.

Key Capabilities

Create custom short URLs, set automatic expiration times, and protect links with secret keys. Users can sign up to track their shortened URLs and access detailed analytics by appending a + to any short link. The dashboard provides visibility into link performance and usage patterns.

Flexible Deployment

Pygmy supports SQLite, MySQL, and PostgreSQL, and ships with Docker images for rapid deployment. Whether you're running a personal instance or deploying for an organization, the straightforward setup and configuration files make hosting simple. The REST API enables programmatic link creation and management, while the shell interface supports scripting and automation workflows.

Highlights

Custom short codes and auto-expiring links with secret key protection
User authentication with personal dashboards and link tracking
Real-time analytics accessible by appending + to any short URL
REST API and shell interface for programmatic access and automation

Pros

  • Loosely coupled architecture simplifies custom integrations and extensions
  • Supports multiple databases (SQLite, MySQL, PostgreSQL) out of the box
  • Docker images and docker-compose configuration enable fast deployment
  • Built-in analytics and user management without third-party dependencies

Considerations

  • Requires Python 3 environment and familiarity with Flask/Django stack
  • Two separate config files (pygmy.cfg and settings.py) increase setup complexity
  • Limited documentation for advanced customization and API usage
  • UI and API run as separate services, adding operational overhead

Managed products teams compare with

When teams consider Pygmy, these hosted platforms usually appear on the same shortlist.

Bitly logo

Bitly

URL shortening and link management service for creating concise, trackable links with analytics

Cutt.ly logo

Cutt.ly

URL shortener with branded links, QR codes, and analytics

Rebrandly logo

Rebrandly

Branded URL shortener and link management

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Teams needing full control and privacy over link shortening infrastructure
  • Developers comfortable with Python who want to extend or integrate shortening logic
  • Organizations requiring link analytics and user-based tracking without SaaS fees
  • Self-hosting enthusiasts looking for a Docker-ready URL shortener

Not ideal when

  • Non-technical users seeking a zero-configuration, hosted SaaS solution
  • Projects requiring high-traffic CDN integration or advanced load balancing
  • Teams without Python expertise or DevOps resources for maintenance
  • Use cases demanding real-time collaboration features or advanced reporting dashboards

How teams use it

Internal Marketing Campaigns

Marketing teams create branded short links with expiration dates for time-sensitive promotions, tracking click-through rates via the built-in analytics dashboard.

Secure Document Sharing

Operations teams generate secret-protected short URLs for confidential documents, ensuring only authorized recipients with the key can access the content.

API-Driven Link Management

Developers integrate Pygmy's REST API into existing applications to programmatically shorten URLs, retrieve analytics, and manage link lifecycles without manual intervention.

Personal Link Organization

Individuals self-host Pygmy to create memorable short links for portfolios, blogs, and social profiles, maintaining full ownership and privacy of their data.

Tech snapshot

Python81%
HTML14%
JavaScript2%
Shell1%
CSS1%
Dockerfile1%

Tags

pygmyanalyticspython3flaskshortenerpythonurlshortenerdjangourl-shortener

Frequently asked questions

Which databases does Pygmy support?

Pygmy works with SQLite (default), MySQL, and PostgreSQL. You configure the database engine, credentials, and connection details in the pygmy.cfg file.

How do I view analytics for a shortened link?

Append a plus sign (+) to the end of any short URL (e.g., demo.pygy.co/pygmy+) to access detailed link statistics including hit counters and timestamps.

Can I create custom short codes instead of random ones?

Yes, Pygmy supports custom short URLs. You can specify your own short code when creating a link, such as pygy.co/pygmy, instead of accepting an auto-generated code.

Does Pygmy require separate servers for the API and UI?

Pygmy's architecture separates the Flask REST API and Django UI layer, but the included run.py script uses gunicorn to serve both components together for simplified deployment.

Is there a command-line interface for link management?

Yes, Pygmy includes a shell interface (./shell) that provides a Python REPL with context for shortening, unshortening, and managing links programmatically without the web UI.

Project at a glance

Dormant
Stars
722
Watchers
722
Forks
139
LicenseMIT
Repo age8 years old
Last commit2 years ago
Self-hostingSupported
Primary languagePython

Last synced yesterday