Metadata-Version: 2.4
Name: babismm
Version: 1.0.1
Summary: A professional, robust, and highly pythonic client for SMM (Social Media Marketing) panels.
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Dynamic: license-file

# SMM Panel Client

A professional, robust, and highly pythonic API client for SMM (Social Media Marketing) panels.

Developed with performance, reliability, and security in mind, this package acts as a standard client compatible with any SMM panel using the Perfect Panel or similar API v2 format.

## Features

- **Connection Pooling**: Reuses TCP connections via `requests.Session()` to make sequential requests blazing fast.
- **Context Manager Support**: Easily manage resources using the `with` statement.
- **Robust Exception Handling**: Offers descriptive custom exception classes for different error categories (network, response formatting, and API errors).
- **Flexible Order Management**: Supports standard, custom comments, package, drip-feed, and **Subscription** orders out of the box.
- **Security-First**: Excludes the API Key from default object representations (`__repr__`) to prevent accidental leaks in logs.
- **Modern User-Agent**: Configured with a modern browser User-Agent to prevent Cloudflare and WAF blockers from rejecting requests.

---

## Installation

You can install the package directly from PyPI:

```bash
pip install babismm
```

---

## Quick Start

### Basic Usage

```python
from smm import SMM, SMMError, SMMAPIError

# Initialize the client
API_URL = "https://your-smm-panel-domain.com/api/v2"
API_KEY = "your_secret_api_key"

with SMM(api_url=API_URL, api_key=API_KEY) as client:
    try:
        # Check balance
        balance_info = client.get_balance()
        print(f"Current Balance: {balance_info['balance']} {balance_info['currency']}")

        # Get list of services
        services = client.get_services()
        print(f"Total services available: {len(services)}")

    except SMMAPIError as e:
        print(f"API Error occurred: {e}")
    except SMMError as e:
        print(f"An SMM client error occurred: {e}")
```

### Creating Orders

#### 1. Standard Order
```python
order = client.add_order(
    service=100,  # Service ID
    link="https://www.instagram.com/p/abcdefg/",
    quantity=1000
)
print(f"Order placed successfully. Order ID: {order['order']}")
```

#### 2. Subscription Order (No link/quantity required)
```python
subscription = client.add_order(
    service=205,          # Subscription Service ID
    username="john_doe",
    min=100,              # Min likes per post
    max=500,              # Max likes per post
    posts=10,             # Cover next 10 posts
    delay=5               # Delay in minutes
)
print(f"Subscription active. ID: {subscription['order']}")
```

#### 3. Drip-Feed Order
```python
drip_feed = client.add_order(
    service=120,
    link="https://www.youtube.com/watch?v=xxxx",
    quantity=1000,
    runs=5,
    interval=60          # 60 minutes between runs
)
print(f"Drip-feed order created: {drip_feed['order']}")
```

---

## Error Handling

This package provides granular exceptions to handle different failure modes:

- `SMMError`: Base exception for all errors.
- `SMMNetworkError`: Raised during TCP connection failures, timeouts, or when the server responds with a non-2xx HTTP status.
- `SMMResponseError`: Raised when the response is not valid JSON (e.g. if the panel returns a Cloudflare block page or maintenance page).
- `SMMAPIError`: Raised when the HTTP response is 200 OK but contains a panel-level error message like `{"error": "Invalid API key"}`.

Example:
```python
from smm import SMM, SMMNetworkError, SMMResponseError, SMMAPIError

try:
    client.get_balance()
except SMMNetworkError as e:
    print("Network issue or SMM server down.")
except SMMResponseError as e:
    print(f"Invalid response from server. Status: {e.status_code}")
except SMMAPIError as e:
    print(f"API rejected the request: {e}")
```

---

## License

This project is licensed under the MIT License - see the LICENSE file for details.
