quote-rss-plugin/README.md
2025-08-13 18:49:19 +08:00

138 lines
3.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# RSS Plugin for Quote/0
## 项目简介
RSS Plugin for Quote/0 是一个基于 Python Flask 的 RSS API 服务,致力于为 [quote/0 墨水屏摆件](https://dot.mindreset.tech/) 拓展更多场景的数据接口。项目目前已支持加密货币行情(如 ETH-USDC未来可扩展服务器监控、天气、资讯等多种 RSS 数据源,助力墨水屏设备实现更多创意玩法。
> 了解 quote/0 墨水屏摆件的更多玩法与社区创意,推荐阅读:[少数派专栏介绍](https://sspai.com/post/100304)
---
## ⚠️ 免责声明
本项目部分或全部代码由 [GitHub Copilot](https://github.com/features/copilot) AI 辅助生成,仅供学习与交流使用。请勿直接用于生产环境或商业用途,使用前请充分审核和测试。
[![GitHub Copilot enabled](https://img.shields.io/badge/Copilot-Enabled-4B8BBE?logo=github&logoColor=white)](https://github.com/features/copilot)
[![Powered by AI](https://img.shields.io/badge/AI%20Generated-Yes-blueviolet)](https://github.com/features/copilot)
---
## 主要功能
- **REST API 服务**:输出标准 RSS 格式数据,适配墨水屏等低功耗设备
- **OKX 实时行情**:通过 OKX 官方 SDK 获取 ETH-USDC 最新价格
- **30 秒缓存机制**:减少外部 API 请求,提升响应速度
- **可扩展架构**:支持未来扩展更多数据源或监控功能
- **健壮的错误处理与日志**
---
## 技术栈
- Python 3.x
- Flask
- okx-sdk
- requests
- websockets
- XML 生成
---
## 目录结构
```
quote-rss-show/
├── app.py # 主 Flask 应用
├── requirements.txt # 项目依赖
├── config.py # 配置文件(建议用环境变量管理敏感信息)
├── services/ # 服务层
│ ├── base_service.py
│ └── crypto_service.py
├── handlers/ # RSS 内容处理器
│ ├── base_handler.py
│ ├── crypto_handler.py
│ └── registry.py
└── utils/ # 工具类
└── rss_generator.py
```
---
## 快速开始
### 1. 克隆项目
```bash
git clone <your-repo-url>
cd quote-rss-show
```
### 2. 创建虚拟环境并安装依赖
```bash
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate
pip install -r requirements.txt
```
### 3. 配置 OKX API 密钥
建议通过环境变量配置密钥,或在 `config.py` 中填写(不推荐将密钥提交到仓库)。
### 4. 启动服务(开发模式)
```bash
python app.py
```
访问:
- [http://127.0.0.1:5000/](http://127.0.0.1:5000/) 查看 API 文档
- [http://127.0.0.1:5000/rss/crypto?pair=ETH-USDC](http://127.0.0.1:5000/rss/crypto?pair=ETH-USDC) 获取 ETH-USDC 价格 RSS
---
## 生产部署建议
- 使用 Gunicorn 等 WSGI 服务部署(如:`gunicorn -w 4 -b 0.0.0.0:5000 app:app`
- 推荐用 Supervisor 或 systemd 守护进程
- 前置 Nginx 反向代理,支持 HTTPS
- 关闭 Flask debug做好日志与监控
- 仅开放必要端口,定期更新依赖
---
## API 端点
- `GET /rss/crypto?pair=ETH-USDC`
返回 ETH-USDC 价格的 RSS XML
- `GET /`
API 文档页面
- `GET /health`
健康检查
---
## 相关链接
- [quote/0 墨水屏摆件官网](https://dot.mindreset.tech/)
- [少数派专栏介绍](https://sspai.com/post/100304)
---
## LICENSE
MIT
---
## 致谢
- [OKX 官方 Python SDK](https://github.com/burakoner/okx-sdk)