Skip to main content

py_easy_qunjielong

群接龙开放平台 Python SDK,提供简单易用的群接龙开放平台 API 交互功能,支持认证、订单查询、商品查询等操作。

功能特性

  • 认证管理:支持获取和刷新 access_token
  • 信息查询:支持获取群接龙信息
  • 同步/异步支持:同时支持同步和异步操作
  • 缓存管理:支持使用 diskcache 或 redis 缓存 access_token
  • 灵活配置:支持通过参数自定义客户端行为
  • 响应处理:提供 JSON 数据验证功能
  • 类型提示:完整的类型注解,提供良好的 IDE 支持

安装

使用 pip 安装

pip install py_easy_qunjielong

从源码安装

git clone https://gitee.com/guolei19850528/py_easy_qunjielong.git
cd py_easy_qunjielong
pip install -e .

依赖

  • httpx
  • diskcache
  • redis
  • py_easy_httpx

快速开始

同步操作

from py_easy_qunjielong.open import Open

# 初始化群接龙开放平台客户端
qjl_client = Open(
    secret="YOUR_SECRET"
)

# 刷新 access_token
qjl_client.refresh_access_token()

# 获取群接龙信息
response = qjl_client.get_home_info()
print(f"群接龙信息: {response}")

异步操作

import asyncio
from py_easy_qunjielong.open import Open

async def main():
    # 初始化群接龙开放平台客户端
    qjl_client = Open(
        secret="YOUR_SECRET"
    )
    
    # 刷新 access_token
    await qjl_client.refresh_access_token()
    
    # 异步获取群接龙信息
    response = await qjl_client.async_request(
        method="GET",
        url="/open/api/ghome/getGhomeInfo"
    )
    print(f"群接龙信息: {response}")

asyncio.run(main())

API 文档

Open 类

初始化参数

  • base_url: API 基础 URL,默认为 "https://openapi.qunjielong.com"
  • secret: 群接龙开放平台密钥
  • cache_config: 缓存配置
  • client_kwargs: 传递给 httpx.Client 的额外参数

方法

  • request(client=None, **kwargs): 同步发送请求
  • async_request(client=None, **kwargs): 异步发送请求
  • get_access_token(client=None, **kwargs): 获取认证 token
  • get_home_info(client=None, **kwargs): 获取群接龙信息
  • refresh_access_token(client=None, get_access_token_kwargs=None, get_home_info_kwargs=None): 刷新 access_token

高级用法

缓存配置

使用 diskcache

import diskcache
from py_easy_qunjielong.open import Open

# 创建缓存实例
cache = diskcache.Cache("./cache")

# 初始化群接龙开放平台客户端
qjl_client = Open(
    secret="YOUR_SECRET",
    cache_config={
        "instance": cache,
        "expire": 7100  # 缓存过期时间(秒)
    }
)

# 刷新 access_token
qjl_client.refresh_access_token()

# 获取群接龙信息
response = qjl_client.get_home_info()
print(f"群接龙信息: {response}")

使用 redis

import redis
from py_easy_qunjielong.open import Open

# 创建 redis 实例
redis_client = redis.Redis(host="localhost", port=6379, db=0)

# 初始化群接龙开放平台客户端
qjl_client = Open(
    secret="YOUR_SECRET",
    cache_config={
        "instance": redis_client,
        "expire": 7100  # 缓存过期时间(秒)
    }
)

# 刷新 access_token
qjl_client.refresh_access_token()

# 获取群接龙信息
response = qjl_client.get_home_info()
print(f"群接龙信息: {response}")

项目结构

py_easy_qunjielong/
├── py_easy_qunjielong/              # 主包目录
│   ├── __init__.py            # 包初始化文件
│   └── open.py                # 开放平台API客户端模块
├── README.md                  # 项目文档
├── setup.py                   # 安装配置
├── requirements.txt           # 依赖列表
├── LICENSE                    # 许可证文件
├── deploy.sh                  # 部署脚本
├── .gitignore                 # Git 忽略文件
└── test_open.py               # 测试文件

测试

运行测试:

# 运行测试
python test_open.py

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

联系方式

致谢

  • httpx - 高性能的异步 HTTP 客户端库
  • diskcache - 简单易用的本地缓存库
  • redis - 高性能的键值存储
  • py_easy_httpx - 简化 HTTP 请求的工具包

Metadata

Release files for py-easy-qunjielong 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for py-easy-qunjielong 1.0.1
File Interpreter ABI Platform
py_easy_qunjielong-1.0.1-py3-none-any.whl Python 3 none any Details

Release files / py_easy_qunjielong-1.0.1-py3-none-any.whl

Download URL py_easy_qunjielong-1.0.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fced1b71cee89df440e11e30a2089c2827e67e780a44a0b9c8e41bc1674a94f4
BLAKE2b-256 checksum
How to use checksums
9183943d57e3155c0bb2491098d18096776fb0c9923fe05ae84e6d580d1f14f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Security for py-easy-qunjielong 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page