Official Python SDK for the AWSYS.CO URL Shortener API
Project description
awsysco — Official Python SDK
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
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Make your changes and add tests
- Run
pytest— all tests must pass - 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
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 awsysco-1.1.0.tar.gz.
File metadata
- Download URL: awsysco-1.1.0.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cc82311b3a1fba0b63f8af2ce86f4bff6a0bf473bca0336a0c7efcc842409f5
|
|
| MD5 |
7b30d7302ffbe3e9e04de1a942fda51f
|
|
| BLAKE2b-256 |
d879f334468c7ea9170285dcc70d3794b037c07918469264c88ec2a30ee01e6b
|
Provenance
The following attestation bundles were made for awsysco-1.1.0.tar.gz:
Publisher:
publish.yml on AlphaWaveSystems/awsysco-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awsysco-1.1.0.tar.gz -
Subject digest:
0cc82311b3a1fba0b63f8af2ce86f4bff6a0bf473bca0336a0c7efcc842409f5 - Sigstore transparency entry: 1704437381
- Sigstore integration time:
-
Permalink:
AlphaWaveSystems/awsysco-python-sdk@e185cfb0efcaa0768b9493d7392bf9438d49858b -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AlphaWaveSystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e185cfb0efcaa0768b9493d7392bf9438d49858b -
Trigger Event:
push
-
Statement type:
File details
Details for the file awsysco-1.1.0-py3-none-any.whl.
File metadata
- Download URL: awsysco-1.1.0-py3-none-any.whl
- Upload date:
- Size: 37.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8207058289efcb8c0c95dab765050afcd3d74275fc4b6e25e6bac6d8555b149
|
|
| MD5 |
960765295cc834dc655b462e749e4141
|
|
| BLAKE2b-256 |
83fda752ea57d05030e19dbe566db2e90c014de14735d33f95cdac6745936105
|
Provenance
The following attestation bundles were made for awsysco-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on AlphaWaveSystems/awsysco-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
awsysco-1.1.0-py3-none-any.whl -
Subject digest:
d8207058289efcb8c0c95dab765050afcd3d74275fc4b6e25e6bac6d8555b149 - Sigstore transparency entry: 1704437437
- Sigstore integration time:
-
Permalink:
AlphaWaveSystems/awsysco-python-sdk@e185cfb0efcaa0768b9493d7392bf9438d49858b -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AlphaWaveSystems
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e185cfb0efcaa0768b9493d7392bf9438d49858b -
Trigger Event:
push
-
Statement type: