Skip to content

Repository files navigation

微信服务号全 API 平台

基于 FastAPI 的微信服务号 API 代理平台,覆盖全部 19 大类、190+ 个接口。

快速开始

1. 启动服务

# Windows 双击运行
start.bat

# 或手动
pip install -r requirements.txt
uvicorn main:app --reload --port 8080

2. 内网穿透(必须)

# 方式一:ngrok(推荐)
ngrok http 8080

# 方式二:frp(若有自建服务器)

记下 ngrok 输出的 https://xxx.ngrok-free.app 地址。

3. 配置微信测试号

  1. 打开 https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo
  2. 记下 appIDappsSecret
  3. 填写"接口配置信息":
    • URL:https://xxx.ngrok-free.app/wx
    • Token:自定义字符串,如 mytoken123
  4. 点击"提交"(服务必须已启动)
  5. 打开 http://localhost:8080 → 配置页填入凭据

4. 使用平台

  • 概览 — 粉丝统计 + 接入说明
  • 粉丝管理 — 查看关注/取关记录
  • 发送消息 — 模板消息单选/群发
  • 消息记录 — 发送历史
  • 配置 — 管理 AppID/Secret
  • API 调试 — 在线调用任意微信 API

项目结构

wechat-platform/
├── main.py                    # FastAPI 入口 + 微信回调 + 管理 API
├── core/                      # 共享基础设施
│   ├── config.py              # config.json 热加载
│   ├── database.py            # SQLite (WAL 模式)
│   ├── wechat_client.py       # 统一微信 API 客户端
│   └── models.py              # 共享 Pydantic 模型
├── routers/                   # 19 个 API 分类 Router
│   ├── basic.py               #   1. 基础接口 (5)
│   ├── openapi_mgmt.py        #   2. openApi管理 (5)
│   ├── menu.py                #   3. 自定义菜单 (7)
│   ├── message.py             #   4. 消息与订阅 (18)
│   ├── customer_service.py    #   5. 客服消息 (15)
│   ├── material.py            #   6. 素材管理 (9)
│   ├── draft.py               #   7. 草稿管理 (8)
│   ├── comment.py             #   8. 留言管理 (8)
│   ├── publish.py             #   9. 发布能力 (5)
│   ├── user.py                #  10. 用户管理 (16)
│   ├── qrcode.py              #  11. 二维码/短链 (7)
│   ├── datacube.py            #  12. 数据统计 (21)
│   ├── web_dev.py             #  13. 网页开发 (5)
│   ├── ai.py                  #  14. 智能接口 (12)
│   ├── store.py               #  15. 微信门店 (12)
│   ├── invoice.py             #  16. 微信发票 (20)
│   ├── nontax.py              #  17. 非税缴费 (10)
│   ├── marketcode.py          #  18. 一物一码 (6)
│   └── medical.py             #  19. 就医助手 (1)
├── static/
│   └── index.html             # 管理后台 SPA
├── config.json
├── requirements.txt
└── start.bat

API 文档

启动后访问:http://localhost:8080/docs

核心 API

接口 方法 说明
/api/user/fans GET 粉丝列表
/api/user/fans-count GET 粉丝统计
/api/message/template-send POST 发单条模板消息
/api/message/template-broadcast POST 群发模板消息
/api/message/template-list GET 模板列表
/api/message/messages GET 消息记录
/api/token GET Token 状态
/api/config GET/POST 配置管理

其余 180+ 个接口按分类分布在 /api/{category}/* 路径下。

About

WeChat test platform - FastAPI + SQLite

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages