用途:通过统一脚本向 HMDB(https://hmdb.ca)提交紧凑检索请求,面向代谢物、蛋白质、疾病与通路,返回简洁摘要。
主要能力:所有 HMDB 调用统一使用 scripts/rest_request.py;支持指定 base_url、path、method、params、headers、json_body、form_body、record_path、response_format、max_items、max_depth、timeout_sec、save_raw、raw_output_path 等字段。默认返回精简 markdown 摘要;若需完整载荷,可设置 save_raw=true 并报告保存路径。
使用方式:脚本从 stdin 读取一个 JSON 对象,必填 base_url 与 path。检索优先使用 unearth/q,并显式给出 query、category 与 format=json;搜索端点建议 per_page=10、max_items=10。示例:echo '{"base_url":"https://hmdb.ca","path":"unearth/q","params":{"query":"serotonin","category":"metabolites","format":"json","per_page":10},"record_path":"metabolites","max_items":10}' | python scripts/rest_request.py
输出:成功返回 ok、source、path、method、status_code、warnings,以及紧凑记录或摘要;失败返回 ok=false 及 error.code 与 error.message。
限制:请求应保持按类别收窄,避免跨多个类别宽泛检索;长对话中应重新执行请求而非依赖旧输出;工具预览中的 ... 为界面截断,并非实际请求内容;参考资料除本文件与 scripts/rest_request.py 外无额外运行时依赖。