Skip to main content

Official Python SDK for the AWSYS.CO URL Shortener API

Project description

awsysco — Official Python SDK

PyPI version Python versions License: MIT

The official Python SDK for the AWSYS.CO URL Shortener API.

Installation

pip install awsysco

Requires Python 3.9+.

Quick Start

from awsysco import Client

client = Client(api_key="awsys_your_key_here")

# Shorten a URL
link = client.links.create("https://example.com/very/long/path")
print(link.short_url)  # https://awsys.co/abc123

# Get analytics
stats = client.analytics.get_stats(link.short_code)
print(f"Total clicks: {stats.total_clicks}")

# Build a QR code URL
qr_url = client.qr.get_url(link.short_code, size=400)
print(qr_url)

Authentication

Generate an API key from your AWSYS dashboard. All API keys begin with awsys_.

client = Client(api_key="awsys_...")

Store keys in environment variables — never hardcode them:

import os
from awsysco import Client

client = Client(api_key=os.environ["AWSYS_API_KEY"])

API Reference

Links

Method Description
client.links.create(url, *, custom_slug, expires_at, max_clicks) Create a shortened link
client.links.list(*, limit=20, offset=0) List links (paginated)
client.links.get(short_path) Get a single link
client.links.update(short_path, *, expires_at, max_clicks) Update link settings
client.links.delete(short_path) Delete a link
# Create with options
link = client.links.create(
    "https://example.com",
    custom_slug="my-link",
    expires_at="2025-12-31T23:59:59Z",
    max_clicks=1000,
)

# Paginate
page1 = client.links.list(limit=20, offset=0)
page2 = client.links.list(limit=20, offset=20)

# Update
updated = client.links.update("my-link", max_clicks=500)

# Delete
client.links.delete("my-link")

Analytics

Method Description
client.analytics.get_stats(short_path) Get click stats for a link
stats = client.analytics.get_stats("abc123")
print(stats.total_clicks)
for click in stats.clicks:
    print(click.country, click.device, click.timestamp)

QR Codes

Method Description
client.qr.get_url(short_code, *, size=300, color='000000', bg_color='FFFFFF') Build QR image URL

No HTTP request is made — this method constructs and returns the URL string.

url = client.qr.get_url("abc123", size=400, color="FF5733", bg_color="FFFFFF")
# https://awsys.co/api/qr/abc123?size=400&color=FF5733&bgColor=FFFFFF

Folders

Method Description
client.folders.list() List all folders
client.folders.create(name, *, color) Create a folder
client.folders.delete(folder_id) Delete a folder
client.folders.assign_link(short_path, folder_id) Assign a link to a folder
client.folders.remove_link(short_path) Remove a link from its folder
folder = client.folders.create("Q1 Campaign", color="#FF5733")
client.folders.assign_link("abc123", folder.id)

folders = client.folders.list()
for f in folders.folders:
    print(f.name, f.link_count)

client.folders.remove_link("abc123")
client.folders.delete(folder.id)

Bulk Create

Method Description
client.bulk.create(urls) Create multiple links in one request
result = client.bulk.create([
    {"url": "https://example.com/page-1"},
    {"url": "https://example.com/page-2", "custom_slug": "page-two"},
    {"url": "https://example.com/page-3", "max_clicks": 100},
])
print(f"Created: {result.created}, Failed: {result.failed}")
for r in result.results:
    print(r.short_url, r.success)

Me

Method Description
client.me.get() Get the authenticated user's profile
me = client.me.get()
print(me.email, me.subscription_tier, me.is_premium)

Error Handling

All errors inherit from AwsysError.

from awsysco import (
    Client,
    AwsysError,
    AwsysAuthError,
    AwsysForbiddenError,
    AwsysNotFoundError,
    AwsysConflictError,
    AwsysValidationError,
    AwsysRateLimitError,
)

try:
    link = client.links.get("nonexistent")
except AwsysNotFoundError:
    print("Link not found")
except AwsysAuthError:
    print("Invalid API key")
except AwsysConflictError as e:
    print(f"Slug already taken: {e.message}")
except AwsysValidationError as e:
    print(f"Bad request: {e.message} ({e.code})")
except AwsysRateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except AwsysError as e:
    print(f"API error {e.status}: {e.message}")
Exception HTTP Status When raised
AwsysValidationError 400 Invalid request parameters
AwsysAuthError 401 Missing or invalid API key
AwsysForbiddenError 403 Insufficient permissions
AwsysNotFoundError 404 Resource does not exist
AwsysConflictError 409 Custom slug already taken
AwsysRateLimitError 429 Too many requests
AwsysError 5xx Server errors

All exceptions expose .message, .code, .status, and .raw attributes.

Rate Limiting

The SDK automatically retries on 429 Too Many Requests with exponential backoff (up to 3 retries). The Retry-After response header is respected.

from awsysco import AwsysRateLimitError

try:
    link = client.links.create("https://example.com")
except AwsysRateLimitError as e:
    print(f"Still rate limited after retries. Retry after: {e.retry_after}s")

Custom Base URL

# Point at staging
client = Client(
    api_key="awsys_...",
    base_url="https://staging.awsys.co",
)

Context Manager

with Client(api_key="awsys_...") as client:
    link = client.links.create("https://example.com")
    print(link.short_url)
# HTTP connections are closed automatically

Models

All responses are parsed into Pydantic v2 models:

Model Fields
Link id, short_url, short_code, long, clicks, created, expires_at, max_clicks, password_protected
LinkList links, total, has_more
LinkStats short_code, total_clicks, clicks
ClickEvent timestamp, country, device, browser, os, referrer
Folder id, name, color, link_count, created_at
FolderList folders, limit, used
BulkResult created, failed, results
BulkLinkResult success, short_url, long, error
MeResponse uid, email, subscription_tier, user_prefix, is_premium, features, limits

Development Setup

git clone https://github.com/AlphaWaveSystems/awsysco-python-sdk.git
cd awsysco-python-sdk

pip install -e ".[dev]"

# Configure test credentials
cp .env.example .env.test
# Edit .env.test — add your AWSYS_API_KEY (staging recommended)

# Run tests
pytest

# Run with coverage
pytest --cov=awsysco --cov-report=term-missing

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/my-feature)
  3. Make your changes and add tests
  4. Run pytest — all tests must pass
  5. Open a pull request

Please read SECURITY.md before contributing — never commit API keys.

License

MIT License — see LICENSE for details.

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

awsysco-0.1.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

awsysco-0.1.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: awsysco-0.1.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for awsysco-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a44756250662a1f1ceaf30f9ea13180dd0ff059b042553ca3176c5d8bff3d21
MD5 b62c394bfc405053050a43d097151eb5
BLAKE2b-256 6a3142cc1d22e83a3fd68d1c8594d4e23db8777c01e4e9673182aad1d96daf55

See more details on using hashes here.

Provenance

The following attestation bundles were made for awsysco-0.1.0.tar.gz:

Publisher: publish.yml on AlphaWaveSystems/awsysco-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: awsysco-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for awsysco-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06db47409aa636397034a5c4c2bd7fd29456a8c2f2488dd93a490161da9ed9a0
MD5 942d2fcc252a6d3599247d24dbe2ebfe
BLAKE2b-256 64308d1ea6c5794165891535c1cc993a3048f907853ef868c4a5423118a6b9e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for awsysco-0.1.0-py3-none-any.whl:

Publisher: publish.yml on AlphaWaveSystems/awsysco-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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