Skip to main content

ME Frp 5.0 Official Python SDK

Project description

ME Frp Python SDK

ME Frp 5.0 的官方 Python SDK,支持同步和异步两种调用模式。

安装

推荐使用 uv 进行安装和管理。

仅同步支持 (requests)

uv add MEFrpLib --optional sync
# 或者使用 pip
pip install MEFrpLib[sync]

仅异步支持 (aiohttp)

uv add MEFrpLib --optional async
# 或者使用 pip
pip install MEFrpLib[async]

全部安装

uv add MEFrpLib --optional all
# 或者使用 pip
pip install MEFrpLib[sync,async]

快速开始

同步模式

from MEFrpLib import MEFrpClient

# 初始化客户端
client = MEFrpClient()

# 登录
client.login("username", "password", "captcha_token")

# 获取用户信息
user_info = client.get_user_info()
print(f"欢迎回来, {user_info.username}! 剩余流量: {user_info.traffic} MB")

# 获取隧道列表
proxies_resp = client.get_proxy_list()
for proxy in proxies_resp.proxies:
    print(f"隧道: {proxy.proxyName} -> {proxy.domain}:{proxy.remotePort}")

异步模式

import asyncio
from MEFrpLib import AsyncMEFrpClient

async def main():
    # 使用上下文管理器自动管理 session
    async with AsyncMEFrpClient() as client:
        # 登录
        await client.login("username", "password", "captcha_token")
        
        # 获取用户信息
        user_info = await client.get_user_info()
        print(f"用户: {user_info.username}")
        
        # 获取节点列表
        nodes = await client.get_node_list()
        for node in nodes:
            print(f"节点: {node.name} ({node.region})")

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

异常处理

SDK 定义了以下异常:

  • MEFrpError: 所有 SDK 异常的基类
  • APIError: 当 API 返回非 200 状态码或业务错误时抛出
  • AuthError: 身份验证失败(如 Token 无效)时抛出
  • NetworkError: 网络请求失败或超时时抛出
from MEFrpLib import MEFrpClient, APIError

client = MEFrpClient(token="your_token")
try:
    info = client.get_user_info()
except APIError as e:
    print(f"API 错误: {e.message} (代码: {e.code})")

开发指南

如果您想参与开发、构建或对代码进行格式化,请确保已安装 uv

初始化环境

# 克隆仓库后
uv sync --all-extras

代码检查与格式化

# 检查并自动修复
uvx ruff check . --fix

# 格式化代码
uvx ruff format .

构建与发布

项目使用 uv 进行构建和发布。

  1. 构建分发包

    uv build
    

    构建完成后,dist/ 目录下会生成 .tar.gz (sdist) 和 .whl (wheel) 文件。

  2. 发布到 PyPI(需要权限):

    uv publish
    

提示:GitHub Actions 已配置为在发布新 Release 时自动使用 uv 构建并发布到 PyPI。

开源协议

AGPL v3

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

mefrplib-3.1.0.tar.gz (149.2 kB view details)

Uploaded Source

Built Distribution

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

mefrplib-3.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file mefrplib-3.1.0.tar.gz.

File metadata

  • Download URL: mefrplib-3.1.0.tar.gz
  • Upload date:
  • Size: 149.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mefrplib-3.1.0.tar.gz
Algorithm Hash digest
SHA256 7eac98f18f818ba45564cae32b9589d86ef67aab9f053fc2fb2b0f538677813a
MD5 1da4f2756fd16a809f647b39f6753b7d
BLAKE2b-256 455cba70c8b3c0366195b927eb0c53fb49d0ef077dccbafd9fa3a5f7b92bada0

See more details on using hashes here.

File details

Details for the file mefrplib-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: mefrplib-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mefrplib-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2b79a79e812897e1a227790f91516bd00262c3d744fe0e41c8cfe63a30994e
MD5 38098eed05e0340ac334ee18e0523403
BLAKE2b-256 f05df4cf5663152182bd0b8364edbb7fffe80281b655f6f09abd481fa1ad1933

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