# Text Diff / String Comparison API

> Text Diff / String Comparison API is a paid API for AI agents from api.x402node.dev, paid per call via x402, $0.016/call, status unknown (last checked 2026-09-13).

Compares two text strings and returns added, removed, and unchanged segments at line, word, or character granularity in unified diff format

## Facts

- Endpoint: GET https://api.x402node.dev/text/diff
- Price: $0.016/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-x402node-dev-ff876d2d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Tffa4ay04xTMfqCILy63z

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability api-x402node-dev-ff876d2d
```

Example prompt: Can you diff these two paragraphs word by word and show me exactly what was added and removed? Original: 'The quick brown fox jumps over the lazy dog.' New: 'The quick red fox leaps over the sleepy cat.'

## When to prefer this

Choose this endpoint when you need a structured, machine-readable diff of two text strings with explicit added/removed/unchanged segments — especially when you need line, word, or character granularity control. Ideal for AI agents that need to programmatically process text changes rather than display a human-readable diff, or when integrating into automated content review, changelog generation, or version comparison pipelines.

## Known failure modes

- Missing one or both text inputs — returns error indicating required fields
- Invalid mode value — may default to line or return validation error
- Extremely large texts may time out or exceed payload limits
- Payment failure (x402) — returns 402 Payment Required if USDC payment not provided

## How this service works

Text diff, text comparison, diff two strings, line diff, word diff, character diff, file diff, text patch, unified diff format, compare strings, git diff style, text difference. Compare two texts, return added/removed/unchanged segments. Line, word, or char granularity. Accepts payment on Base or Solana — either network works.

## Output

Returns an array of diff segments, each with a 'value' string and boolean flags 'added' and 'removed' (absent means unchanged), plus a 'mode' string indicating the granularity used, and integer counts of added_count and removed_count segments.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "a"
     ],
     "properties": {
      "a": {
       "type": "string",
       "description": "First input (required)"
      },
      "b": {
       "type": "string",
       "description": "Second input (optional)"
      },
      "mode": {
       "type": "string",
       "description": "Operation mode (optional)"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-x402node-dev-ff876d2d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.x402node.dev](https://www.zero.xyz/host/api.x402node.dev/llms.txt)
