Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YEB ShortLinksAPI

PHP SDK for the YEB Short Links API. Create, manage and track shortened URLs.

Works standalone (plain PHP) or with Laravel (Facade + auto-discovery).

Requirements

  • PHP 8.1+
  • cURL extension
  • YEB API Key (free tier available)

Installation

composer require yebto/short-links-api

Standalone Usage

use Yebto\ShortLinksAPI\ShortLinksAPI;

$api = new ShortLinksAPI(['key' => 'your-api-key']);
$result = $api->create('example');

Laravel Usage

Add your API key to .env:

YEB_KEY_ID=your-api-key

Use via Facade:

use ShortLinksAPI;

$result = ShortLinksAPI::create('example');

Or via dependency injection:

use Yebto\ShortLinksAPI\ShortLinksAPI;

public function handle(ShortLinksAPI $api)
{
    $result = $api->create('example');
}

Publish Config

php artisan vendor:publish --tag=yebto-short-links-config

Available Methods

Method Description
create($url) Create a short link (alias for create-basic)
createBasic($url) Create a basic short link
createAdvanced($url) Create an advanced short link with options
get($code) Get short link details
update($code) Update a short link
delete($code) Delete a short link
stats($code) Get click statistics for a short link

All methods accept an optional $extra array parameter for additional API options.

Error Handling

use Yebto\ApiClient\Exceptions\ApiException;
use Yebto\ApiClient\Exceptions\AuthenticationException;
use Yebto\ApiClient\Exceptions\RateLimitException;

try {
    $result = $api->create('example');
} catch (AuthenticationException $e) {
    // Missing or invalid API key (401)
} catch (RateLimitException $e) {
    // Too many requests (429)
} catch (ApiException $e) {
    echo $e->getMessage();
    echo $e->getHttpCode();
}

Free API Access

Register at yeb.to with Google OAuth to get a free API key.

Support

License

MIT - NETOX Ltd.

About

PHP SDK for the YEB Short Links API. Create, manage and track shortened URLs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages