Skip to main content

A python Client for 3X-UI client

Project description

3X-UI API Client

Overview

This project provides a Python client for interacting with the 3X-UI API.

It supports both synchronous and asynchronous operations, making it suitable for various use cases and performance requirements.

Features

  • Synchronous Client: For straightforward and blocking API calls.
  • Asynchronous Client: For non-blocking operations to improve performance and scalability.
  • Payload Class: Simplifies payload creation and formatting for API requests.

Installation

pip install client3x

Requirements

  • Python 3.6 or higher
  • requests library
  • aiohttp library

Usage

Here are examples of working with synchronous and asynchronous clients and working with the default payload class. For further information, you can refer to Documentation or look at usage examples

To see what the methods return, it is recommended to visit this link .

Synchronous Client Example

from client3x import Client3XUI
from config import *

# Initialize the client
client = Client3XUI(
    login=PANEL_LOGIN,
    password=PANEL_PASSWORD,
    login_key=PANEL_SECRET_KEY,
    panel_host=PANEL_HOST,
    root_url=PANEL_ROOT_URL,
    sub_host=SUB_HOST,
    sub_path=SUB_PATH,
    inbound_id=INBOUND_ID,
    panel_port=PANEL_PORT,
    sub_port=SUB_PORT,
    logging_enabled=CLIENT_LOGGING_ENABLED
)

# Get info about all connections
info = client.info_about_all_clients()   

Asynchronous Client Example

import asyncio
from client3x import AsyncClient3XUI
from config import *


async def main():
    # Initialize the client
    client = AsyncClient3XUI(
        login=PANEL_LOGIN,
        password=PANEL_PASSWORD,
        login_key=PANEL_SECRET_KEY,
        panel_host=PANEL_HOST,
        root_url=PANEL_ROOT_URL,
        sub_host=SUB_HOST,
        sub_path=SUB_PATH,
        inbound_id=INBOUND_ID,
        panel_port=PANEL_PORT,
        sub_port=SUB_PORT,
        logging_enabled=CLIENT_LOGGING_ENABLED
    )
    client.start()
    # Get info about all connections
    info = await client.info_about_all_clients()


asyncio.run(main())

DefaultPayload Example

from client3x import CLientPayload

payload = ClientPayload(12345, "aaaa-aaaa-aaaa-aaaa",
                        "john.doe@example.com", 3,
                        17000000000, "1234567890")
print(str(payload))

# Inbound: 12345,
# Settings: {'clients': [{'email': 'john.doe@example.com',
#               'enable': True,
#               'expiryTime': 17000000000,
#               'flow': 'xtls-rprx-vision',
#               'id': 'aaaa-aaaa-aaaa-aaaa',
#               'limitIp': 3,
#               'reset': 0,
#               'subId': '1234567890',
#               'totalGB': 0}]}

Contributing

Contributions are welcome! Please fork this repository and submit pull requests.


License

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


Contact

For any issues or inquiries, please open an issue on the GitHub repository.

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

client3x-1.2.1.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

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

client3x-1.2.1-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file client3x-1.2.1.tar.gz.

File metadata

  • Download URL: client3x-1.2.1.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for client3x-1.2.1.tar.gz
Algorithm Hash digest
SHA256 bdabf9a055725f9a7b8e6e84b5e88bf0195006fe0010609e8d7c02cdaf907847
MD5 b7d91cac8f92275f1e29beec759eb8b5
BLAKE2b-256 c437b97df3068b8133534656c5c94d8de9551d3523d397eecf69fe040bead390

See more details on using hashes here.

File details

Details for the file client3x-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: client3x-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for client3x-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36971a392bdf906a7038fedcb7e6ada99601479802e7476df419c4e170a42bbe
MD5 8fd15c9a52f37db795f8b18e21a82b1c
BLAKE2b-256 80d0095e8c99f68878517fedea0585f27a33e9b313607dbeab94cf8c3612737f

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