Dataify Python SDK
Python 客户端库,直接调用 Dataify 上游 REST 接口(不走 MCP 协议),用于网页采集与搜索引擎抓取。
功能
- 🔍 搜索引擎 — Google(17 种)、Bing(6 种)、Yandex、DuckDuckGo,走
POST /request - 🛒 平台抓取器 — Amazon、YouTube、TikTok、Facebook、Instagram、Reddit、Twitter/X、LinkedIn、Glassdoor、Indeed、Walmart、Zillow、Airbnb、Booking、Crunchbase、eBay、GitHub 等 45 个采集器,先走
POST /builder?platform=1,再可查询任务状态并下载结果 - 🌐 AI Web — 聚合搜索、站点发现、正文提取和结果下载,见 docs/AI_WEB.md
- 📖 参数全暴露 — 每个工具函数把上游请求参数、类型、是否必填、中文描述都写在签名与 docstring 里;离线参数手册由维护者通过
scripts/codegen.py生成 - 🐍 零依赖 — 仅用标准库
urllib,同步 API
安装
pip install dataify-sdk
要求 Python >= 3.10。
快速开始
from dataify_sdk import DataifyClient
from dataify_sdk.tools.amazonproduct import amazon_product_by_asin
from dataify_sdk.tools.googlesearch import google_search
# token 也可通过环境变量 DATAIFY_API_TOKEN 提供(兼容旧版 DATAIFY_TOKEN)
client = DataifyClient(token="YOUR_TOKEN")
# 采集类:先提交 Builder 任务
task = amazon_product_by_asin(asin="B0BZYCJK89", client=client)
task_id = task["data"]["task_id"]
# 再查询任务状态
status = client.query_scraper_task_status(task_id)
if status["data"]["status"] == "成功":
result = client.download_scraper_task_result(task_id, result_type="json")
# 搜索类:直接打搜索引擎接口
result = google_search(q="pizza", client=client)
也可以不传 client,使用默认 client(优先读取 DATAIFY_API_TOKEN,兼容 DATAIFY_TOKEN):
export DATAIFY_API_TOKEN="..."
from dataify_sdk.tools.googlesearch import google_search
result = google_search(q="pizza")
client.query_scraper_task_status(...) 会返回任务状态 JSON,data.status 常见值为 处理中、成功、失败。任务成功后可用 client.download_scraper_task_result(task_id, result_type="json") 下载最终结果;result_type 支持 json、csv、xlsx。
AI Web
AI Web 的搜索、站点发现和正文提取通过 client.ai_web 调用,默认使用正式域名 https://aiwebapi.dataify.com。测试或私有网关可通过 AI_WEB_API_BASE_URL 或 ai_web_base_url 覆盖。
from dataify_sdk import AI_WEB_UNIQUE_IDS, DataifyClient
client = DataifyClient() # 默认从 DATAIFY_API_TOKEN 读取 token
result = client.ai_web.search(
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
"OpenAI",
max_results=3,
source="web",
)
print(result.request_id)
print(result.outputs)
page = client.ai_web.extract(
AI_WEB_UNIQUE_IDS.EXTRACT,
"https://example.com/article",
formats=["markdown"],
)
search 支持 SEARCH_WEB、SEARCH_NEWS、SEARCH_SHOPPING、SEARCH_SCHOLAR 四种模式。search、map、extract 返回 AIWebResponse(request_id, outputs),其中 outputs 统一为数组;execute / execute_raw 支持动态 operation,download_result 通过 request_id 下载结果。完整参数和示例见 docs/AI_WEB.md。
API 设计
- 每个
spider_id= 一个独立函数(采集类),例如amazon_product_by_asin()、amazon_product_by_url()、amazon_product_by_keywords()。 - 搜索类每个引擎一个函数,例如
google_search()、bing_search()、yandex_search()。 - 所有函数签名与 docstring 完整暴露上游参数及其描述;离线参数手册由维护者通过
scripts/codegen.py生成。 - 函数返回解析后的 JSON
dict(即上游原始响应)。
错误处理
from dataify_sdk import DataifyClient, DataifyAPIError, DataifyConnectionError
client = DataifyClient(token="YOUR_TOKEN")
try:
result = google_search(q="pizza", client=client)
except DataifyAPIError as e:
print(f"上游返回错误 HTTP {e.status_code}: {e.body}")
except DataifyConnectionError:
print("无法连接 Dataify 上游")
开发
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
pytest
# 从 Go 参考项目重新生成工具函数与参数手册
python scripts/codegen.py
许可
MIT License
Metadata
Release files for dataify-sdk 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dataify_sdk-1.3.1.tar.gz | 63.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dataify_sdk-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 201.4 kB
Release files / dataify_sdk-1.3.1.tar.gz
| Download URL | dataify_sdk-1.3.1.tar.gz |
|---|---|
| Size | 63.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45cf00b4857bcd599eba1983bfcb57dd0c6098e238c10c33ec103fc56b527b9a
|
|
BLAKE2b-256 checksum How to use checksums |
5c158d6ffc7e189184b46704a63650a3f8d881933ddcf043916e386dda0e7174
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / dataify_sdk-1.3.1-py3-none-any.whl
| Download URL | dataify_sdk-1.3.1-py3-none-any.whl |
|---|---|
| Size | 138.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
848a46b9009309de55cbfb5615fe0c9e3ccc2f83425a3de89ac3c0138680b878
|
|
BLAKE2b-256 checksum How to use checksums |
7feb729efe51c28337f05a937a7245c0fe9772b839cedfcff5ea7762394c59bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Security for dataify-sdk 1.3.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.