Shlink
Open-source, self-hosted URL shortener with REST API, QR code generation, and analytics.
Why consider Shlink?
Shlink is a self-hosted, open-source URL shortener built with PHP that provides both REST and CLI interfaces for seamless integration.
Learn Shlink by building
Practical setup notes, real use cases, and copy-ready examples in one focused guide.
In this guide4 sections
Shlink: The Definitive Self-Hosted URL Shortener
Operating your own URL shortener provides ultimate control over your links, branding, and visit data. Shlink is a self-hosted, open-source URL shortener built with PHP that provides both REST and CLI interfaces for seamless integration. By hosting Shlink on your own infrastructure, you can confidently share links knowing that the underlying data remains fully under your administration.
Core Features and Shortening Links
The primary function of the platform is to reliably process and redirect web traffic. Shlink allows converting long URLs into short ones by automatically generating a unique code. If you prefer branded or memorable links, the platform also supports custom human-friendly slugs. This flexibility ensures that your marketing campaigns or personal shares look professional and trustworthy. You can learn more about these core features on the Shlink official website.
When distributing these links across social networks or emails, the platform tracks each click, collecting anonymized visit statistics and visitor geolocation. This data is critical for understanding audience engagement and geographic reach without relying on third-party tracking services that might compromise user privacy or inject unwanted advertisements.
Managing Your Instance via REST API
For developers looking to embed link generation within their own applications, a REST API is included out of the box to help integrate link management into third-party systems. Shlink's API is designed to be predictable and easy to consume. API requests return JSON responses along with semantic status codes for straightforward client implementation. Detailed endpoint specifications can be reviewed in the REST API documentation.
Whether you are building a custom web portal, a mobile application, or a simple automation script, the REST API exposes all the necessary endpoints to create, list, and manage short URLs programmatically. This ensures that your link infrastructure can scale seamlessly alongside your custom software solutions.
Administration and CLI Tooling
While Shlink can be configured using environment variables—which is particularly useful when deploying via Docker—administrators can configure their instance using a dedicated CLI installation tool instead of environment variables. This tool is accessible through the terminal and guides you through the setup process. Further instructions are available in the CLI installation tool guide.
For instance, if you are running Shlink via Docker and need to generate your first API key to start using the REST API, you can execute the following official command within your container:
docker exec -it my_shlink shlink api-key:generateThis command accesses the Shlink CLI inside the my_shlink container to instantly provision a new API key. From there, you can securely authenticate your external applications and begin shortening URLs.
Conclusion
By offering a powerful REST API, comprehensive CLI management, and robust tracking capabilities, Shlink stands out as a premium choice for self-hosted link management. Its commitment to retaining data ownership while providing modern development interfaces makes it an essential tool for developers and marketers alike.
Related tools
More options with a similar category or technology profile.
ActivityWatch
The leading privacy-first, open-source automated time and application tracker.
Traggo
Tag-based time tracking server with visual statistics and dashboards.
Prefect
Prefect is a Python workflow orchestration framework.
Apache Airflow
Apache Airflow is a platform for authoring, scheduling, and monitoring batch workflows as Python DAGs.