T.LY Tools How To

Introducing the T.LY Laravel URL Shortener API Package

Introducing the T.LY Laravel URL Shortener API Package

If you need short links inside a Laravel app, the T.LY API already gives you the building blocks. The TLY Laravel package makes that workflow feel more native, so you can create, update, and inspect links without wiring up every request yourself.

T.LY API Docs on the t.ly domain showing the authenticated API reference used by Laravel integrations.

Why Use the T.LY API for URL Shortening?

T.LY is a simple URL shortener that goes beyond just shrinking links. By leveraging the T.LY API, you can:

  • Generate short URLs with ease.
  • Access analytics and click metrics.
  • Organize and manage your shortened URLs through tags and dashboards.
  • Maintain brand consistency by using custom domains.

If you want those features inside a Laravel app, the tly/laravel-url-shortener-api package keeps the integration simple.

Getting Started


Create an API Key

  1. Register a T.LY Account
  2. Create an API Token

Installation

Install via Composer:

composer require tly/laravel-url-shortener-api

Publish the configuration:

php artisan vendor:publish --provider="TLY\\LaravelUrlShortener\\TLYServiceProvider" --tag=config

Set your API token in .env:

TLY_API_TOKEN=your_api_token_here

Examples


Create a Short Link

use TLY\LaravelUrlShortener\Facades\TLYApi;

$response = TLYApi::create([
    'long_url' => 'https://example.com',
    'description' => 'Example Link',
]);

Update a Short Link

use TLY\LaravelUrlShortener\Facades\TLYApi;

$response = TLYApi::update([
    'short_url' => 'https://t.ly/123',
    'long_url' => 'https://new-destination.com',
    'description' => 'Updated Link Description',
    'expire_at_datetime' => '2035-12-31 23:59:59',
]);

Delete a Short Link

use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::delete('https://t.ly/123');

Get a Short Link

use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::get('https://t.ly/123');

Get the stats for a Short Link

use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::stats('https://t.ly/123');

The TLY Laravel URL Shortener API package gives Laravel apps a clean way to work with T.LY. If you need branded short links, stats, or tags, it saves you from rebuilding the same plumbing by hand.

For more details, visit the T.LY documentation.

Free tools

Put it into practice with T.LY

Create branded short links, dynamic QR codes and OneLinks, and see every click in one place.