Skip to main content

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

Documentation

Project details


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.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lix_sdk-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file lix_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: lix_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for lix_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 964b985e7ee3d81a1d07a2fda651e427716df2245c08c936fe8264fb5dafda9b
MD5 d91386f3862dd9ca5cd3bf15cb943fe7
BLAKE2b-256 48b1722364d1076a2e013824b78ae48866d7fbaad3c77658fb0f90a8ce3df59d

See more details on using hashes here.

File details

Details for the file lix_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lix_sdk-0.1.0-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

Hashes for lix_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ecdd445bcd19cc6d4e3cf598cffd08a83a38ca4779f2d9f6bdfd5d54a8cc7c9
MD5 0537ace598eeea702fc91f365a2d849f
BLAKE2b-256 3f1de2cfbbc6e60b56637d54d94035728a1e1c686aad10d4841e67585d2449e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page