Install via pip
Add the SDK to your Python environment.
pip install lix-sdk
Official Python SDK for the Lix.li URL shortening and link analytics API. Built with dataclasses, type hints, and clean keyword arguments. Create short links, manage groups, and track clicks with Pythonic simplicity.
from lix_sdk import Client client = Client('lix_live_xxx') result = client.links().create('https://example.com') print(result.link.short_url) # https://lix.li/a3b7k2 print(result.usage.remaining) # 42
Built with dataclasses, type hints, and clean keyword arguments. Pythonic by design.
Create, get, update, delete, and list short links. Full CRUD with keyword arguments and optional defaults.
Organize links into groups. Create rotating groups for A/B testing landing pages. Full CRUD with typed dataclass responses.
Fetch account profile, plan details, and real-time usage limits for links, API links, and mass links.
Every API response is a @dataclass with full type hints. Clean repr, IDE autocomplete, and natural attribute access.
7 dedicated exception classes extending a base LixException. Catch what you need, access validation error data in .data.
Pass your own requests.Session for custom timeouts, retries, or testing. Falls back to a default session.
Requires Python 3.8+ and requests. Install with pip and start shortening URLs immediately.
Add the SDK to your Python environment.
pip install lix-sdk
Pass your API key. Optionally provide a custom requests.Session for advanced control.
from lix_sdk import Client client = Client('lix_live_xxx') # With custom session import requests session = requests.Session() session.headers.update({'X-Custom-Header': 'value'}) client = Client('lix_live_xxx', session=session)
Shorten a URL and get back a LinkShortenResult with the short URL and usage info.
result = client.links().create('https://example.com') print(result.link.short_url) # https://lix.li/a3b7k2 # API links used: 42 / 100 print(result.usage.used, '/', result.usage.limit)
Create short links with custom aliases, UTM parameters, tracking pixels, password protection, and expiration dates. Every operation returns a typed dataclass.
# Create a basic link result = client.links().create('https://example.com') print(result.link.short_url) # With custom alias and UTM result = client.links().create( 'https://example.com', alias='my-link', title='My Page Title', tags=['sale', 'promo'], utm={'utm_source': 'google', 'utm_medium': 'email', 'utm_campaign': 'summer'}, tracking_pixel_ids=[1001, 1002], is_public=True, ) # Password protection + expiration result = client.links().create( 'https://example.com', password='secret123', active_before_datetime='2026-12-31T23:59:59+00:00', ) # Update a link updated = client.links().update(79697, title='New Title') print(updated.link.title)
Pagination example:
client.links().list(limit=20, from_id=79500)
returns the next 20 links with ResponseMeta containing total count and next URL. Omit both for API defaults.
Groups help you categorize links by campaign, team, or project. Rotating groups enable A/B testing by distributing traffic across multiple links.
# Create a regular group group = client.groups().create('Marketing') print(group.name, group.url) # Create a rotating group for A/B testing group = client.groups().create( 'Landing Pages', description='Rotating landing pages', is_rotate=True, ) # Update group group = client.groups().update( 10, description='Updated description', ) # List with pagination page = client.groups().list(limit=10, from_id=1000) for g in page.groups: print(g.name, g.url) print(page.meta.total)
Fetch your profile, plan, and real-time usage limits — all returned as nested dataclass instances with full attribute access.
profile = client.profile().me() # Account info print(profile.client.name, profile.client.email) print(profile.user.email) # Plan details print(profile.plan.name, profile.plan.end_datetime) # Usage limits print(profile.usages.links.remaining) print(profile.usages.api_links.used) print(profile.usages.mass_links.limit)
Organization and account metadata.
Authenticated user information and account details.
Current subscription and billing period.
API limits, link quotas, and remaining usage.
Catch exactly what you need. All exceptions extend LixException. ValidationException includes the full field-level error data in .data.
from lix_sdk import ( ValidationException, NotFoundException, UnauthorizedException, RateLimitException, ServerException, ) try: result = client.links().create('invalid-url') except ValidationException as e: # Field-level validation errors print('Validation:', e.data) except NotFoundException: print('Not found') except UnauthorizedException: # Invalid API key except RateLimitException: # Too many requests — retry after except ServerException: # 5xx server error except LixException as e: # Generic SDK error print('Error:', e)
400 — Invalid input. Access e.data for field errors.
401 — Invalid API key or missing auth.
404 — Link or group not found.
429 — Rate limit exceeded.
500 — Unexpected Server-side error.
Network / transport failure.
All exceptions extend LixException, which extends Exception. Catch the base class for any SDK error, or target specific classes for granular handling.
The same clean API, idiomatically implemented in your language of choice.
Install the SDK, get your API key, and start creating short links in under a minute.