Metadata-Version: 2.4
Name: u2l
Version: 0.1.0
Summary: Official Python client for the U2L AI API — create and manage short links, QR codes, and analytics (u2l.ai)
Project-URL: Homepage, https://u2l.ai
Project-URL: Documentation, https://u2l.ai/developers/sdk
Project-URL: API Reference, https://u2l.ai/developers
Author: U2L AI
License-Expression: MIT
License-File: LICENSE
Keywords: api client,link management,qr codes,short links,u2l,url shortener
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# u2l

Official Python client for the [U2L AI](https://u2l.ai) URL shortener API.

Zero dependencies (standard library only). Python 3.9+.

```bash
pip install u2l
```

## Quick start

```python
from u2l import U2L

client = U2L(api_key="u2l_live_...")  # free at u2l.ai -> Settings -> API

link = client.links.create(url="https://example.com/some/long/page")
print(link["shortLink"])  # https://u2l.ai/abc1234
```

## Usage

Field names match the API exactly (camelCase) — full schema at
[u2l.ai/developers/openapi.json](https://u2l.ai/developers/openapi.json).

```python
# Create with options
client.links.create(
    url="https://mysite.com/launch",
    alias="launch24",
    title="Launch day",
    domain="auto",          # or one of your domains
    tags=["campaign"],
    expiresAt="2027-01-01T00:00:00Z",
)

# QR code
client.links.create(url="https://mysite.com", type="QR")

# Get / update / delete (addressed by domain + slug)
client.links.get("u2l.ai", "launch24")
client.links.update("u2l.ai", "launch24", title="Launch day (updated)")
client.links.delete("u2l.ai", "launch24")

# List with filters and pagination
page = client.links.list(search="launch", sort="clicks", order="desc", page=1, limit=25)
for link in page["links"]:
    print(link["shortLink"], link.get("clicks", 0))

# Domains available to your account
client.domains.list()

# Per-link analytics (Advanced+ plans)
client.analytics.get("u2l.ai", "launch24")

# Account info and usage stats
client.account.get()
client.account.stats()
```

## Error handling

Every non-2xx response raises `U2LApiError` with the API's status, error
code, and (on 429s) how long to wait:

```python
from u2l import U2L, U2LApiError

client = U2L(api_key="u2l_live_...")

try:
    client.links.create(url="https://example.com", alias="taken")
except U2LApiError as error:
    print(error.status)       # e.g. 409
    print(error.code)         # e.g. "alias_taken"
    print(error)              # human-readable message
    if error.status == 429:
        print(error.retry_after)  # seconds to wait
```

## Rate limits

After any request, `client.rate_limit` holds the latest `X-RateLimit-*`
header values:

```python
client.account.get()
print(client.rate_limit)
# {"limit": 10, "remaining": 9, "reset": 1753500000,
#  "daily_limit": 500, "daily_remaining": 499}
```

## Links

- [API documentation](https://u2l.ai/developers)
- [Rate limits per plan](https://u2l.ai/developers/rate-limits)
- [JavaScript/TypeScript SDK](https://www.npmjs.com/package/@u2l/sdk)

MIT
