Skip to main content

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

Support

Need help with the API or SDK?

Documentation

Release files for lix-sdk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lix-sdk 0.1.1
File Size Uploaded
lix_sdk-0.1.1.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lix-sdk 0.1.1
File Interpreter ABI Platform
lix_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / lix_sdk-0.1.1.tar.gz

Download URL lix_sdk-0.1.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dd9891170861b900bb4fc7b9330e2fc102e5bbcdd721c471791d028f9afaf33b
BLAKE2b-256 checksum
How to use checksums
a4caf12b88947b74dbaddf716c6b04df008b341721758c9edd87ae4c20e7e99b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / lix_sdk-0.1.1-py3-none-any.whl

Download URL lix_sdk-0.1.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c0c76fa9c42497e729ed520fb91bd99bd735e3e37e14caf4cfde51689076ca3
BLAKE2b-256 checksum
How to use checksums
73cc43c7e8d0c22f865911eb60544764601f93ba9dbc95e32d87b8ea7ece0497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page