Skip to main content

Python client library for Sinkron - Give your agent permanent email addresses through Clawhub

Project description

Sinkron Python Library

Python library and CLI for Sinkron API - Give your agent permanent email addresses through Clawhub.

Features

  • Full API Support: Access all Sinkron API endpoints
  • CLI Interface: Easy-to-use command line tool
  • Configuration Management: Save tokens and API URLs
  • Input Validation: Robust validation for all inputs
  • Error Handling: Detailed error messages
  • Modular Design: Use as a library or CLI

Installation

From source

cd library
pip install -e .

From PyPI (when published)

pip install sinkron

Quick Start

Using CLI

# Register a new agent
sinkron register --username john --name "John Doe" --save-token

# Check your inbox
sinkron inbox

# Check a specific page
sinkron inbox --page 2

# Search messages
sinkron inbox --search "verification"

# Get a specific message
sinkron message 123

# Check if email exists
sinkron check john@sinkron.id

# Delete messages
sinkron delete-messages --ids 1,2,3

# Delete entire inbox
sinkron delete-inbox

# Get agent info
sinkron agent john

# Config management
sinkron config --show
sinkron config --token YOUR_TOKEN
sinkron config --api-url https://api.sinkron.id

Using as Library

from sinkron import SinkronClient

# Initialize client
client = SinkronClient()

# Register new agent
result = client.register("john", "John Doe")
print(f"Token: {result.token}")

# Set token for authenticated requests
client.token = result.token

# Get inbox
inbox = client.get_inbox(page=1)
print(f"Total messages: {inbox.total}")

# Get specific message
message = client.get_message(123)
print(f"Subject: {message.subject}")

# Check email exists
check = client.check_email("john@sinkron.id")
print(f"Exists: {check.exists}")

Configuration

Environment Variables

Config File

The CLI stores configuration in ~/.sinkron.json:

{
  "api_url": "https://api.sinkron.id",
  "token": "your_token_here"
}

CLI Options

All CLI commands accept these global options:

  • --api-url URL - Override API URL
  • --token TOKEN - Override authentication token
  • --version - Show version

Local Development

For local development, you can use the Cloudflare Workers local server:

# Start local development server
cd /home/zororaka/Project/sinkron/be
wrangler dev

Then use the local URL in your commands:

# Register using local server
sinkron register --username john --name "John Doe" --save-token --api-url http://localhost:8787

# Or save the local URL to config
sinkron config --api-url http://localhost:8787
sinkron register --username john --name "John Doe" --save-token

Setting Custom Domain

If you have a custom domain configured:

sinkron config --api-url https://your-custom-domain.com

API Reference

Client Methods

Method Description Auth Required
health_check() Check API health No
register(username, name) Register new agent No
get_agent_info(username) Get agent info Yes
get_inbox(page, search) Get inbox messages Yes
delete_inbox() Delete entire inbox Yes
get_message(id) Get message by ID Yes
delete_messages(ids) Delete messages Yes
check_email(address) Check email exists No

CLI Commands

sinkron health                              # Check API health
sinkron register --username USER --name NAME # Register new agent
sinkron inbox [--page N] [--search KEYWORD] # Get inbox
sinkron check ADDRESS                       # Check email exists
sinkron message ID                          # Get message
sinkron delete-messages --ids 1,2,3         # Delete messages
sinkron delete-inbox [--force]              # Delete inbox
sinkron agent USERNAME                      # Get agent info
sinkron config --show                       # Show config
sinkron config --token TOKEN                # Set token
sinkron config --clear-token                # Clear token

Error Handling

from sinkron import SinkronClient
from sinkron.exceptions import (
    SinkronError,
    SinkronAuthError,
    SinkronNotFoundError,
    SinkronRateLimitError,
    SinkronValidationError,
)

client = SinkronClient()

try:
    result = client.register("john", "John Doe")
except SinkronValidationError as e:
    print(f"Validation error: {e}")
except SinkronAuthError as e:
    print(f"Auth error: {e}")
except SinkronRateLimitError as e:
    print(f"Rate limited: {e}")
except SinkronError as e:
    print(f"API error: {e}")

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black sinkron/

# Lint
flake8 sinkron/

License

MIT License - see LICENSE file for details.

Links

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

sinkron-1.0.2.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

sinkron-1.0.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file sinkron-1.0.2.tar.gz.

File metadata

  • Download URL: sinkron-1.0.2.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sinkron-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a8ae7b60e3d1f5e75b0a9eabfbfad6185275da370e858c34523de06be41fe4b7
MD5 effe698ff7e9726216d1a2f958b25d61
BLAKE2b-256 6df43f9065756ee59ea29f09f56888b2d1791e5fac373bba0a5206ceae27d4df

See more details on using hashes here.

File details

Details for the file sinkron-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: sinkron-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sinkron-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0deaf7f789dd8a69825bf75193d2065649ebf7eabcd5770cc5aed5b24b41f15c
MD5 65573ad457c412dbedbf2a329a18aa0d
BLAKE2b-256 257f1c4d37beb829d9440a499692c537a69581492d54f26c9550f0ee02b543a8

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