Official PHP SDK for the Lix.li API.
Lix.li is a URL shortening and link analytics platform with support for custom aliases, groups, tags, UTM parameters and detailed click tracking.
- PHP 8.2+
- Composer
composer require lix-url/php-sdkuse Lix\Client;
$client = new Client('lix_live_xxx');
$link = $client->links()->create('https://example.com');
echo $link->link->shortUrl;Get information about the authenticated account.
$profile = $client->profile()->get();
echo $profile->user->email;$link = $client->links()->create(
url: 'https://example.com'
);
echo $link->link->shortUrl;$link = $client->links()->create(
url: 'https://example.com',
alias: 'my-link'
);$link = $client->links()->create(
url: 'https://example.com',
utm: [
'source' => 'newsletter',
'medium' => 'email',
'campaign' => 'summer-sale',
]
);$link = $client->links()->get(123);
echo $link->url;
echo $link->shortUrl;$link = $client->links()->update(
id: 123,
title: 'Updated title'
);$client->links()->delete(123);$linksResponse = $client->links()->list();
foreach ($linksResponse->links as $link) {
echo $link->shortUrl . PHP_EOL;
}$links = $client->links()->list(
limit: 100,
fromId: 500
);$group = $client->groups()->create(
name: 'Marketing'
);
echo $group->name;$group = $client->groups()->create(
name: 'Landing Pages',
isRotate: true
);$group = $client->groups()->get(10);$group = $client->groups()->update(
groupId: 10,
description: 'Updated description'
);$client->groups()->delete(10);$response = $client->groups()->list(limit: 10, fromId: 1000);
foreach ($response->groups as $group) {
echo $group->name . PHP_EOL;
}use Lix\Exceptions\UnauthorizedException;
use Lix\Exceptions\ValidationException;
try {
$client->links()->create(
url: 'invalid-url'
);
} catch (ValidationException $e) {
// Validation failed
// Validation error fields data
var_dump($e->data);
} catch (UnauthorizedException $e) {
// Invalid API key
}- API Documentation: https://lix.li/api
- OpenAPI Specification: https://github.com/lix-url/openapi
- Go SDK: https://github.com/lix-url/go-sdk
- JavaScript SDK: https://github.com/lix-url/js-sdk
- Python SDK: https://github.com/lix-url/python-sdk
Need help with the API or SDK?
- Support Center: https://lix.li/support
MIT