{"mode":"words","changes":{"added_blocks":1,"removed_blocks":0,"equal":2},"diff":[{"value":"hello ","added":false,"removed":false},{"value":"brave ","added":true,"removed":false},{"value":"world","added":false,"removed":false}],"unified_patch":"===================================================================\n--- a\n+++ b\n@@ -1,1 +1,1 @@\n-hello world\n\\ No newline at end of file\n+hello brave world\n\\ No newline at end of file\n"}
curl --location --request POST 'https://zylalabs.com/api/13164/text+difference+and+patch+api/26710/compare+two+texts' --header 'Authorization: Bearer YOUR_API_KEY'
--data-raw '{"a": "hello world", "b": "hello brave world", "mode": "words"}'
注册后,每个开发者都会被分配一个个人 API 访问密钥,这是一个唯一的字母和数字组合,用于访问我们的 API 端点。要使用 Text Difference and Patch API 进行身份验证,只需在 Authorization 标头中包含您的 bearer token。
| 标头 | 描述 |
|---|---|
授权
|
必需
应为 Bearer access_key. 订阅后,请查看上方的"您的 API 访问密钥"。
|
无长期承诺。随时升级、降级或取消。 免费试用包括最多 50 个请求。
(年度计费可节省 2 个月 🎉)
领先企业的信赖之选
See exactly what changed between two texts. One call compares them by lines, words or characters and returns both a structured, machine readable difference and a unified patch string, the same format version control tools use.
Useful for tracking revisions of contracts, articles and documentation, audit logs that must show exactly what changed, review robots for configuration files, and detecting content changes in monitored pages.
The Compare Two Texts endpoint returns a structured difference between two texts, including parts flagged as added or removed, a summary count of changes, and a unified patch string. This allows users to see exactly what has changed in a clear format.
Key fields in the response include "mode" (indicating the granularity), "changes" (with counts of added and removed blocks), "diff" (showing individual text segments with flags), and "unified_patch" (the formatted patch string).
The response data is organized into a JSON structure. It includes a summary of changes, a detailed list of differences with flags for added or removed text, and a unified patch string formatted for easy application or storage.
用户可以指定“模式”参数以选择比较的粒度:行、词或字符。这允许根据所需的细节级别进行量身定制的比较
典型的使用案例包括跟踪合同的修订审核文章的修改维护文档的审计日志以及监控网页内容的变化确保准确的更改跟踪
用户可以通过分析特定变化的“diff”来利用返回的数据,应用“unified_patch”来更新文档,或者根据添加和删除的文本块的汇总计数生成报告
Data accuracy is maintained by performing in-memory comparisons without storing the texts, ensuring that only the current state of the texts is analyzed, thus providing reliable and immediate results.
Users can expect a consistent structure in the response, with "added" and "removed" flags clearly indicating changes, and a unified patch that follows a standard format similar to version control systems, making it easy to interpret.