tly/laravel-url-shortener-api

A Laravel package for the T.LY URL Shortener API

v1.0.2 2024-12-15 03:04 UTC

This package is not auto-updated.

Last update: 2025-05-19 03:01:34 UTC


README

This package provides a convenient Laravel wrapper for the T.LY URL Shortener API.

T.LY URL Shortener API documentation to create URLs to track, brand, and share short links. This package aims to help you to work with our API. Please see our API Docs if you have any issues.

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

Usage

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');

License

This package is licensed under the MIT License.