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
Release history Release notifications | RSS feed
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 client3x-1.2.0.tar.gz.
File metadata
- Download URL: client3x-1.2.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbd9221e5362ffc4f2188405f3f687dea7bd3c1e0c9bee2436d4bdcaa42bd3ed
|
|
| MD5 |
b1744ec12680f90859ca83b195c01ec8
|
|
| BLAKE2b-256 |
fb90a5fe47ea34c8470fce5241e98d973f9699de2a462e9365aba5ecd85cc603
|
File details
Details for the file client3x-1.2.0-py3-none-any.whl.
File metadata
- Download URL: client3x-1.2.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f4889c690fb4a4ce32002c3abbb6490bcd835a69ce15290ecc73c6a9dc817fc
|
|
| MD5 |
a888cb515613e823e9354a8859c72ea0
|
|
| BLAKE2b-256 |
9a7040e94c69e31a9ef2588af27bf36cebd4de36484227bcb8d13254919b78f6
|