redfox-python-sdk 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. redfox_python_sdk-0.2.2/PKG-INFO +371 -0
  2. redfox_python_sdk-0.2.2/README.md +347 -0
  3. redfox_python_sdk-0.2.2/redfox/__init__.py +13 -0
  4. redfox_python_sdk-0.2.2/redfox/client.py +417 -0
  5. redfox_python_sdk-0.2.2/redfox_python_sdk.egg-info/PKG-INFO +371 -0
  6. redfox_python_sdk-0.2.2/redfox_python_sdk.egg-info/requires.txt +1 -0
  7. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/setup.py +3 -3
  8. redfox-python-sdk-0.2.1/PKG-INFO +0 -48
  9. redfox-python-sdk-0.2.1/README.md +0 -30
  10. redfox-python-sdk-0.2.1/redfox/__init__.py +0 -7
  11. redfox-python-sdk-0.2.1/redfox/client.py +0 -162
  12. redfox-python-sdk-0.2.1/redfox_python_sdk.egg-info/PKG-INFO +0 -48
  13. redfox-python-sdk-0.2.1/redfox_python_sdk.egg-info/requires.txt +0 -1
  14. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/__init__.py +0 -0
  15. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/ai_search.py +0 -0
  16. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/bilibili.py +0 -0
  17. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/doubao_image.py +0 -0
  18. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/doubao_video.py +0 -0
  19. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/douyin.py +0 -0
  20. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/gpt_image.py +0 -0
  21. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/tiktok.py +0 -0
  22. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/toutiao.py +0 -0
  23. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/wechat.py +0 -0
  24. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/endpoints/xiaohongshu.py +0 -0
  25. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox/exceptions.py +0 -0
  26. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox_python_sdk.egg-info/SOURCES.txt +0 -0
  27. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox_python_sdk.egg-info/dependency_links.txt +0 -0
  28. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/redfox_python_sdk.egg-info/top_level.txt +0 -0
  29. {redfox-python-sdk-0.2.1 → redfox_python_sdk-0.2.2}/setup.cfg +0 -0
@@ -0,0 +1,371 @@
1
+ Metadata-Version: 2.4
2
+ Name: redfox-python-sdk
3
+ Version: 0.2.2
4
+ Summary: RedFox 红狐数据平台 Python SDK — 同步+异步双客户端,自动重试,零配置
5
+ Home-page: https://redfox.hk
6
+ Author: RedFox
7
+ Author-email: dev@redfox.hk
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: httpx>=0.25.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ # RedFox Python SDK
26
+
27
+ <div align="center">
28
+ <a href="https://pypi.org/project/redfox-python-sdk/"><img src="https://img.shields.io/pypi/v/redfox-python-sdk.svg" alt="PyPI version"></a> <a href="https://pypi.org/project/redfox-python-sdk/"><img src="https://img.shields.io/pypi/pyversions/redfox-python-sdk.svg" alt="Python"></a> <a href="https://pypi.org/project/redfox-python-sdk/"><img src="https://img.shields.io/pypi/l/redfox-python-sdk.svg" alt="License"></a>
29
+
30
+ <strong>中文</strong> | <a href="https://github.com/redfox-data/redfox-python-sdk/blob/main/README.en.md">English</a> | <a href="https://github.com/redfox-data/redfox-python-sdk/blob/main/README.ko.md">한국어</a> | <a href="https://github.com/redfox-data/redfox-python-sdk/blob/main/README.ja.md">日本語</a> | <a href="https://github.com/redfox-data/redfox-python-sdk/blob/main/README.fr.md">Français</a>
31
+
32
+ </div>
33
+ <p align="center">
34
+ <a href="https://redfox.hk/?source=github">
35
+ <img src="https://lyy.redfox.hk/page/redfox-page-3.png" alt="RedFox Logo" width="100%">
36
+ </a>
37
+ </p>
38
+
39
+ [RedFoxHub](https://redfox.hk/?source=github) Python SDK,提供[抖音](https://redfox.hk/apis/douyin/0OT1E306)、[小红书](https://redfox.hk/apis/xiaohongshu/4IVIDHEN)、[公众号](https://redfox.hk/apis/gongzhonghao/6C4A77XR)、[B站](https://redfox.hk/apis/bilibili/TIN1NMTZ)、[今日头条](https://redfox.hk/apis/jinritoutiao/28CFGF5I)、[TikTok](https://redfox.hk/apis/tool-tiktok/20070019) 六大内容平台的数据采集接口,以及 GPT 图片生成、豆包图片/视频生成、AI 搜索(Kimi/豆包/Deepseek)四大 AI 能力接口。
40
+
41
+ ## 为什么选择 RedFoxHub
42
+
43
+ <p align="center"><em>平台数据限时统一定价,最低可至 <strong style="color:#e53e3e">¥0.02/次</strong></em></p>
44
+
45
+ <table align="center">
46
+ <tr>
47
+ <td align="center" width="25%">
48
+ <b>⚡ 极速响应</b><br>
49
+ <sub>毫秒级 API 响应,全球 CDN 加速,让您的应用快如闪电</sub>
50
+ </td>
51
+ <td align="center" width="25%">
52
+ <b>🛡️ 安全可靠</b><br>
53
+ <sub>企业级安全防护,数据加密传输,99.99% 可用性保证</sub>
54
+ </td>
55
+ <td align="center" width="25%">
56
+ <b>🌍 全球覆盖</b><br>
57
+ <sub>支持全球主流新媒体平台,一键接入多平台数据</sub>
58
+ </td>
59
+ <td align="center" width="25%">
60
+ <b>💎 弹性计费</b><br>
61
+ <sub>按需付费,无隐藏费用,灵活的套餐满足不同需求</sub>
62
+ </td>
63
+ </tr>
64
+ </table>
65
+
66
+ ## SDK 核心特性
67
+
68
+ - **零配置** — 设置环境变量 `REDFOX_API_KEY` 即可使用,无需配置对象,扁平化参数
69
+ - **指数退避自动重试** — 网络超时、服务端 5xx、限流 429 自动重试(含随机抖动防惊群)
70
+ - **同步 + 异步双客户端** — `RedFoxClient` 与 `AsyncRedFoxClient`,API 完全一致
71
+ - **结构化异常** — `RedFoxAuthError` / `RedFoxRateLimitError` / `RedFoxAPIError`,含完整调试上下文
72
+ - **生产就绪** — 基于 `httpx` 构建,支持连接复用、超时控制、上下文管理器
73
+
74
+ ## 安装
75
+
76
+ ```bash
77
+ pip install redfox-python-sdk
78
+ ```
79
+
80
+ ## 身份认证
81
+
82
+ ### 获取 API Key
83
+
84
+ 1. 前往 [https://redfox.hk/settings/api-keys?source=github](https://redfox.hk/settings/api-keys?source=github) 注册 / 登录。
85
+ 2. 在控制台复制你的 API Key。
86
+ 3. 设置为环境变量或直接传入:
87
+
88
+ ```bash
89
+ export REDFOX_API_KEY="YOUR_API_KEY"
90
+ ```
91
+
92
+ ## 多平台API文档
93
+
94
+ <p align="center">
95
+ <a href="https://redfox.hk/apis?source=github">
96
+ <img src="https://lyy.redfox.hk/page/redfox-page-1.png" alt="RedFox Logo" width="100%">
97
+ </a>
98
+ </p>
99
+
100
+ ### API文档中包含:
101
+
102
+ - 请求头说明
103
+ - 请求参数说明
104
+ - 返回值和数据结构说明
105
+ - 请求示例
106
+ - 响应示例
107
+ - 常见状态码说明
108
+
109
+ ## 快速开始
110
+
111
+ ```python
112
+ from redfox import RedFoxClient
113
+
114
+ client = RedFoxClient(api_key="your_api_key")
115
+
116
+ # 搜索抖音作品
117
+ result = client.douyin.search_articles(keyword="AI")
118
+
119
+ # 搜索小红书笔记
120
+ result = client.xiaohongshu.search_articles(keyword="旅行")
121
+
122
+ # 搜索公众号文章
123
+ result = client.wechat.search_articles(keyword="科技")
124
+
125
+ # 获取抖音用户主页
126
+ result = client.douyin.get_user(account_id="nxpt260212")
127
+
128
+ # AI 搜索
129
+ task = client.ai_search.kimi_submit(inquiry_text="2026年AI发展趋势")
130
+ result = client.ai_search.kimi_result(task_id=task["taskId"])
131
+ ```
132
+
133
+ ## 支持的平台
134
+
135
+ | 平台 | 模块 | 方法数 | 说明 |
136
+ |------|------|--------|------|
137
+ | 📱 抖音 | `client.douyin` | 6 | 作品搜索、账号搜索、用户信息、作品详情、AI作品搜索 |
138
+ | 📕 小红书 | `client.xiaohongshu` | 5 | 笔记搜索、账号搜索、账号信息、笔记详情、AI笔记搜索 |
139
+ | 💬 公众号 | `client.wechat` | 7 | 文章搜索、账号搜索、账号信息、文章详情、用户作品列表、AI文章搜索 |
140
+ | 📺 B站 | `client.bilibili` | 5 | 视频搜索、UP主搜索、UP主信息、UP主作品、视频详情 |
141
+ | 📰 今日头条 | `client.toutiao` | 2 | 内容搜索、作品详情 |
142
+ | 🎵 TikTok | `client.tiktok` | 1 | 用户搜索 |
143
+ | 🖼️ GPT 图片 | `client.gpt_image` | 2 | 图片生成、结果查询 |
144
+ | 🎨 豆包图片 | `client.doubao_image` | 4 | Pro/Lite 图片生成及查询 |
145
+ | 🎬 豆包视频 | `client.doubao_video` | 2 | 视频生成、结果查询 |
146
+ | 🔍 AI 搜索 | `client.ai_search` | 6 | Kimi/豆包/Deepseek 搜索 |
147
+
148
+ ## API 参考
149
+
150
+ ### 抖音
151
+
152
+ ```python
153
+ # 搜索抖音作品
154
+ client.douyin.search_articles(keyword="AI", offset=0, sort_type="0")
155
+
156
+ # 搜索抖音用户
157
+ client.douyin.search_users(keyword="科技", offset=0)
158
+
159
+ # 获取账号信息
160
+ client.douyin.get_user(account_id="nxpt260212")
161
+
162
+ # 获取账号作品列表
163
+ client.douyin.get_user_works(account_id="nxpt260212", offset=0)
164
+
165
+ # 获取作品详情
166
+ client.douyin.get_work(work_id="7654143095876898089")
167
+
168
+ # 搜索AI作品
169
+ client.douyin.search_ai_articles(keyword="AI", page_num=1, page_size=10)
170
+ ```
171
+
172
+ ### 小红书
173
+
174
+ ```python
175
+ # 搜索笔记
176
+ client.xiaohongshu.search_articles(keyword="旅行", offset=0, sort_type="0")
177
+
178
+ # 搜索博主
179
+ client.xiaohongshu.search_users(keyword="旅行", offset=0)
180
+
181
+ # 获取博主信息
182
+ client.xiaohongshu.get_account(account_id="5e1e4c8c0000000001023027")
183
+
184
+ # 获取笔记详情
185
+ client.xiaohongshu.get_work(work_id="6a2ac3020000000035022d8e")
186
+
187
+ # 搜索AI笔记
188
+ client.xiaohongshu.search_ai_articles(keyword="AI", page_num=1, page_size=10)
189
+ ```
190
+
191
+ ### 公众号
192
+
193
+ ```python
194
+ # 搜索文章
195
+ client.wechat.search_articles(keyword="AI", offset=0)
196
+
197
+ # 搜索账号
198
+ client.wechat.search_users(keyword="科技", offset=0)
199
+
200
+ # 获取账号信息
201
+ client.wechat.get_account(account="rmrbwx")
202
+
203
+ # 获取文章详情(支持全文内容)
204
+ client.wechat.get_article_detail(url="https://mp.weixin.qq.com/s/...")
205
+
206
+ # 获取文章元数据
207
+ client.wechat.get_work(work_uuid="3F4DE056583609162E0816FBE8C183A3")
208
+
209
+ # 获取账号文章列表
210
+ client.wechat.get_user_works(
211
+ account="rmrbwx", offset=0,
212
+ sort_type="_2",
213
+ publish_time_start="2026-07-01",
214
+ publish_time_end="2026-07-20"
215
+ )
216
+ ```
217
+
218
+ ### B站
219
+
220
+ ```python
221
+ # 搜索视频
222
+ client.bilibili.search_articles(keyword="Python", page=1, page_size=10, order="time")
223
+
224
+ # 搜索UP主
225
+ client.bilibili.search_users(keyword="影视飓风", page=1, page_size=10, order="follower")
226
+
227
+ # 获取UP主信息
228
+ client.bilibili.get_account(mid="946974")
229
+
230
+ # 获取UP主视频列表
231
+ client.bilibili.get_user_works(mid="946974", page=1, page_size=10, order="time")
232
+
233
+ # 获取视频详情
234
+ client.bilibili.get_work(bvid="BV1ghJg6hEWV")
235
+ ```
236
+
237
+ ### 今日头条
238
+
239
+ ```python
240
+ # 搜索内容
241
+ client.toutiao.search_works(keyword="AI", offset=0)
242
+
243
+ # 获取作品详情
244
+ client.toutiao.get_work(opus_id="7592180245936046626")
245
+ ```
246
+
247
+ ### TikTok
248
+
249
+ ```python
250
+ # 搜索用户
251
+ client.tiktok.search_users(keyword="tech", cursor=0)
252
+ ```
253
+
254
+ ### AI 搜索
255
+
256
+ ```python
257
+ # Kimi 搜索
258
+ task = client.ai_search.kimi_submit(inquiry_text="2026年AI发展趋势")
259
+ result = client.ai_search.kimi_result(task_id=task["taskId"])
260
+
261
+ # 豆包搜索
262
+ task = client.ai_search.doubao_submit(inquiry_text="夏日茶饮推荐")
263
+ result = client.ai_search.doubao_result(task_id=task["taskId"])
264
+
265
+ # Deepseek 搜索
266
+ task = client.ai_search.deepseek_submit(inquiry_text="Python性能优化")
267
+ result = client.ai_search.deepseek_result(task_id=task["taskId"])
268
+ ```
269
+
270
+ ### GPT 图片生成
271
+
272
+ ```python
273
+ # 文生图
274
+ task = client.gpt_image.submit(
275
+ prompt="一只坐在窗台上的橘猫,阳光洒在毛发上",
276
+ size="1024x1024",
277
+ quality="medium",
278
+ output_format="png",
279
+ model_name="gpt-image-2",
280
+ operation="generate",
281
+ )
282
+ result = client.gpt_image.result(task_id=task["taskId"])
283
+
284
+ # 图生图/编辑
285
+ task = client.gpt_image.submit(
286
+ prompt="将背景替换成海滩",
287
+ size="1024x1024",
288
+ model_name="gpt-image-2",
289
+ operation="edit",
290
+ input_fidelity=5,
291
+ images=[{"url": "https://example.com/your-image.jpg"}],
292
+ )
293
+ result = client.gpt_image.result(task_id=task["taskId"])
294
+ ```
295
+
296
+ ### 豆包图片生成
297
+
298
+ ```python
299
+ # Pro 模型
300
+ task = client.doubao_image.pro_submit(
301
+ prompt="一座漂浮在云端的未来城市",
302
+ size="2048x2048",
303
+ output_format="jpeg",
304
+ response_format="url",
305
+ watermark=False,
306
+ )
307
+ result = client.doubao_image.pro_result(task_id=task["taskId"])
308
+
309
+ # Lite 模型(支持组图)
310
+ task = client.doubao_image.lite_submit(
311
+ prompt="春夏秋冬四季风景画",
312
+ size="2048x2048",
313
+ output_format="jpeg",
314
+ response_format="url",
315
+ sequential="auto",
316
+ max_images=4,
317
+ )
318
+ result = client.doubao_image.lite_result(task_id=task["taskId"])
319
+ ```
320
+
321
+ ### 豆包视频生成
322
+
323
+ ```python
324
+ # 文生视频
325
+ task = client.doubao_video.submit(
326
+ content=[{"type": "text", "text": "一只猫在阳光下打哈欠,毛发随着微风轻轻飘动"}],
327
+ resolution="720p",
328
+ ratio="16:9",
329
+ duration=5,
330
+ watermark=False,
331
+ generate_audio=True,
332
+ )
333
+ result = client.doubao_video.result(task_id=task["taskId"])
334
+
335
+ # 图生视频
336
+ task = client.doubao_video.submit(
337
+ content=[
338
+ {"type": "text", "text": "让图中的人物微笑并挥手"},
339
+ {"type": "image_url", "image_url": "https://example.com/photo.jpg"},
340
+ ],
341
+ resolution="720p",
342
+ duration=5,
343
+ )
344
+ result = client.doubao_video.result(task_id=task["taskId"])
345
+ ```
346
+
347
+ ## 错误处理
348
+
349
+ SDK 提供三种异常类型:
350
+
351
+ ```python
352
+ from redfox import RedFoxAPIError, RedFoxAuthError, RedFoxRateLimitError
353
+
354
+ try:
355
+ result = client.douyin.search_articles(keyword="AI")
356
+ except RedFoxAuthError as e:
357
+ print(f"认证失败: {e}")
358
+ except RedFoxRateLimitError as e:
359
+ print(f"频率超限: {e}")
360
+ except RedFoxAPIError as e:
361
+ print(f"API错误: code={e.code}, msg={e}")
362
+ ```
363
+
364
+ ## 依赖
365
+
366
+ - Python >= 3.8
367
+ - requests >= 2.25.0
368
+
369
+ ## 许可证
370
+
371
+ MIT License