Metadata-Version: 2.4
Name: silentshop-python-sdk
Version: 1.0.1
Summary: Official Python SDK for SilentShop Store and Account Automation API
Author-email: SilentShop <support@silentshop.shop>
License-Expression: MIT
Project-URL: Homepage, https://silentshop.shop
Project-URL: Documentation, https://silentshop.shop/api-docs
Project-URL: Repository, https://github.com/silentshop/silentshop-python-sdk
Project-URL: Bug Tracker, https://github.com/silentshop/silentshop-python-sdk/issues
Keywords: silentshop,telegram,accounts,api,sdk
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
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: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.20.0

# silentshop-python-sdk

Official Python SDK for the **SilentShop Store and Account Automation API**.

Allows developers to query the product catalog, check user balances, purchase Telegram accounts (Tdata/Session), poll order statuses, and subscribe to back-in-stock notifications.

## Features

- **Sync and Async** Clients (`SilentShop` and `AsyncSilentShop`)
- Fully type-hinted methods
- Robust exception handling mapping HTTP errors to specific exceptions
- Powered by `httpx`

## Installation

```bash
pip install silentshop-python-sdk
```

## Quick Start

### Synchronous Client

```python
from silentshop import SilentShop, SilentShopError

api_key = "your_api_key_here"

# Initialize sync client
with SilentShop(api_key=api_key) as client:
    try:
        # 1. Get profile and balance
        profile = client.get_profile()
        print(f"Telegram ID: {profile['telegram_id']}, Balance: {profile['balance']} USDT")

        # 2. Get available products
        products = client.get_products(country="US", premium=False)
        for p in products:
            print(f"ID: {p['product_id']} | Price: {p['price']} USDT | Stock: {p['stock']}")

        if products:
            target_product = products[0]["product_id"]
            
            # 3. Buy product (quantity = 1)
            order = client.buy(product_id=target_product, quantity=1)
            print(f"Order created! ID: {order['order_id']}, Total Cost: {order['total_cost']} USDT")

            # 4. Get order details / poll status
            import time
            while True:
                status = client.get_order(order_id=order["order_id"])
                print(f"Status: {status['status']}")
                
                if status["status"] == "success":
                    for acc in status["accounts"]:
                        print(f"Phone: {acc['phone']}")
                        print(f"Session string: {acc['session_string']}")
                        print(f"Download Session ZIP: {acc['session_download_url']}")
                    break
                elif status["status"] == "error":
                    print(f"Order failed: {status['message']}")
                    break
                
                time.sleep(3)

    except SilentShopError as e:
        print(f"An error occurred: {e}")
```

### Asynchronous Client

```python
import asyncio
from silentshop import AsyncSilentShop, SilentShopError

async def main():
    api_key = "your_api_key_here"

    # Initialize async client
    async with AsyncSilentShop(api_key=api_key) as client:
        try:
            profile = await client.get_profile()
            print(f"Balance: {profile['balance']} USDT")

            # Get order history
            orders = await client.get_orders(limit=5)
            print(f"Recent orders count: {len(orders)}")

        except SilentShopError as e:
            print(f"API Error: {e}")

if __name__ == "__main__":
    asyncio.run(main())
```

## Exceptions

The SDK maps API and HTTP errors to Python exceptions:

- `AuthenticationError`: Raised when the API key is missing or invalid (401).
- `PaymentRequiredError`: Raised when the account balance is insufficient (402).
- `NotFoundError`: Raised when the requested product or order is not found (404).
- `ValidationError`: Raised when input validation fails (e.g. invalid product ID, quantity <= 0) (400).
- `APIError`: Raised for other backend API failures.
- `SilentShopError`: Base exception class for all custom SDK errors.

## License

MIT License
