Official Python SDK for the Lix.li API.
Project description
Lix.li Python SDK
Official Python SDK for the Lix.li URL shortening and link analytics API.
Requirements
- Python 3.8+
Installation
pip install lix-sdk
Quick Start
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/xxxxx
Links
Create a short link
result = client.links().create('https://example.com')
print(result.link.short_url)
print(result.usage.remaining)
Create a link with a custom alias
result = client.links().create(
'https://example.com',
alias='my-link',
)
print(result.link.short_url) # https://lix.li/my-link
Create a link with all options
result = client.links().create(
'https://example.com',
alias='my-alias',
title='My Page Title',
group_id=42,
tags=['sale', 'promo'],
meta={'title': 'Sale!', 'description': '...'},
utm={'utm_source': 'google', 'utm_medium': 'email', 'utm_campaign': 'summer'},
tracking_pixel_ids=[1001, 1002],
active_before_datetime='2029-12-31T23:59:59+00:00',
password='secret123',
is_public=True,
)
Update a link
result = client.links().update(79697, title='New Title')
print(result.link.title)
Get a link by ID
link = client.links().get(79697)
print(link.short_url)
print(link.url)
print(link.group.name if link.group else None)
List links
response = client.links().list()
# With pagination:
page = client.links().list(limit=20, from_id=79500)
for link in response.links:
print(link.short_url, link.url)
print(response.meta.total)
print(response.meta.next_url)
Delete a link
client.links().delete(79697)
Groups
Create a group
group = client.groups().create('Marketing')
# With options:
group = client.groups().create(
'Landing Pages',
description='Rotating landing pages',
is_rotate=True,
)
Update a group
group = client.groups().update(
10,
description='Updated description',
)
Get a group by ID
group = client.groups().get(10)
print(group.name)
print(group.alias)
print(group.url)
List groups
response = client.groups().list()
# With pagination:
page = client.groups().list(limit=10, from_id=1000)
for group in response.groups:
print(group.name)
print(response.meta.total)
Delete a group
client.groups().delete(10)
Profile
profile = client.profile().me()
print(profile.client.name)
print(profile.user.email)
print(profile.plan.name)
print(profile.usages.api_links.remaining)
print(profile.usages.links.used)
print(profile.usages.mass_links.limit)
Error Handling
from lix_sdk import (
ValidationException,
UnauthorizedException,
NotFoundException,
RateLimitException,
ServerException,
)
try:
result = client.links().create('https://example.com')
except ValidationException as e:
print('Validation errors:', e.data)
except UnauthorizedException:
print('Invalid API key')
except NotFoundException:
print('Resource not found')
except RateLimitException:
print('Rate limit exceeded')
except ServerException:
print('Server error')
Running Tests
pip install -e ".[dev]"
pytest
Project Structure
lix_sdk/
__init__.py — public API exports
client.py — main entry point
exceptions.py — typed exception classes
dto.py — dataclass DTOs
http/
api_client.py — requests-based HTTP wrapper
resources/
links.py — links resource
groups.py — groups resource
profile.py — profile resource
tests/ — pytest test suite
example.py — runnable usage example
Other SDKs
- PHP SDK: https://github.com/lix-url/php-sdk
- JavaScript SDK: https://github.com/lix-url/js-sdk
- Go SDK: https://github.com/lix-url/go-sdk
Support
Need help with the API or SDK?
- Support Center: https://lix.li/support
Documentation
- API Documentation: https://lix.li/api
- OpenAPI Specification: https://github.com/lix-url/openapi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lix_sdk-0.1.1.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lix_sdk-0.1.1.tar.gz.
File metadata
- Download URL: lix_sdk-0.1.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd9891170861b900bb4fc7b9330e2fc102e5bbcdd721c471791d028f9afaf33b
|
|
| MD5 |
d2b1e77d57586798fc113720457a6ac7
|
|
| BLAKE2b-256 |
a4caf12b88947b74dbaddf716c6b04df008b341721758c9edd87ae4c20e7e99b
|
File details
Details for the file lix_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lix_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0c76fa9c42497e729ed520fb91bd99bd735e3e37e14caf4cfde51689076ca3
|
|
| MD5 |
412c1603197d69980834cb44a060404a
|
|
| BLAKE2b-256 |
73cc43c7e8d0c22f865911eb60544764601f93ba9dbc95e32d87b8ea7ece0497
|