POST
text
diff
1 creditCompare two texts and return a unified diff
Endpoint
POST /api/v1/tools/text/diff
Body Parameters
text_a
string
required
text_b
string
required
context_lines
integer
optional
default: 3
Example
input
Request
{
"text_a": "line1\nline2\nline3",
"text_b": "line1\nline2 modified\nline3"
}
output
Response
{
"diff": "--- a\n+++ b\n@@ -1,3 +1,3 @@\n line1\n-line2\n+line2 modified\n line3",
"lines_added": 1,
"lines_removed": 1
}
Response Format
HTTP/1.1 200 OK
SUCCESS
{
"success": true,
"data": {
"diff": "--- a\n+++ b\n@@ -1,3 +1,3 @@\n line1\n-line2\n+line2 modified\n line3",
"lines_added": 1,
"lines_removed": 1
},
"meta": {
"tool": "diff",
"credits_consumed": 1
}
}
HTTP/1.1 422 Unprocessable Entity
ERROR
{
"success": false,
"data": null,
"error": {
"code": "validation_error",
"message": "The given data was invalid."
}
}
Sign in to try this tool directly from the docs.
Code Examples
Request Example
lightbulb
Developer Tip
Credits are deducted before execution. If the upstream tool fails, credits are automatically refunded to your account.