Data processing

JSON

Parses a JSON string, optionally auto-repairs common syntax errors (trailing commas, etc.), and validates against an optional JSON Schema (Draft-07). Returns structured errors with JSON Pointer paths.

MCP tool: validate_json

POST /v1/json/validate

Parameters:

ParameterTypeRequiredDescription
json_strstringJSON string to parse and validate
schemaobject-JSON Schema object (Draft-07). Omit to parse only
auto_repairboolean-Auto-repair syntax errors before parsing (default false)

Request example:

curl -X POST https://api.thousand-api.com/v1/json/validate \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "json_str": "{\"name\": \"Thousand API\", \"features\": [\"MCP\", \"Speed\"]}",
    "schema": {
      "type": "object",
      "required": ["name", "features"],
      "properties": {
        "name": { "type": "string" },
        "features": { "type": "array", "items": { "type": "string" } }
      }
    }
  }'

Response example:

{
  "valid": true,
  "repaired": false,
  "json": {
    "name": "Thousand API",
    "features": ["MCP", "Speed"]
  },
  "errors": []
}

Response:

HTTP 200 is returned even when valid is false (parse or schema errors). When auto_repair succeeds, original contains the input json_str and repaired is true.

Format Validation

Validates IPv4, IPv6, CIDR, email, URL, credit card, and Japanese phone number formats. No external dependencies.

MCP tool: validate_format

GET /v1/validate/{type}

type options

ParameterDescription
ipv4IPv4 address (private / loopback / multicast flags)
ipv6IPv6 address
cidrCIDR notation (network and host count)
emailEmail address (local / domain split)
urlURL (http/https only)
credit_cardCredit card number (Luhn check and brand hint)
phone_jpJapanese phone number

Parameters:

ParameterTypeRequiredDescription
valuestringValue to validate

Request example:

curl "https://api.thousand-api.com/v1/validate/ipv4?value=192.168.1.1" \
  -H "x-api-key: YOUR_API_KEY"

Response example:

{
  "value": "192.168.1.1",
  "type": "ipv4",
  "valid": true,
  "details": {
    "is_private": true,
    "is_loopback": false,
    "is_multicast": false,
    "octets": [192, 168, 1, 1]
  }
}

JSON Merge / Patch

Deep-merge two JSON objects or apply RFC 6902 JSON Patch operations. Useful for config overlays and avoiding full JSON regeneration by agents. Request body max 1MB.

MCP tool: merge_json

POST /v1/json/merge

mode: merge (deep merge)

ParameterTypeRequiredDescription
modestringmerge or patch (default merge)
baseobjectBase JSON object to merge into
patchobjectJSON object to merge
array_strategystring-replace (overwrite) or concat (append). Default replace
null_overwritesboolean-Whether patch null overwrites base. Default true

Request example:

curl -X POST "https://api.thousand-api.com/v1/json/merge" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "merge",
    "base": {
      "app": { "name": "MyApp", "version": "1.0.0" },
      "features": ["auth"]
    },
    "patch": {
      "app": { "version": "1.1.0" },
      "features": ["auth", "billing"],
      "debug": true
    }
  }'

Response example:

{
  "mode": "merge",
  "result": {
    "app": { "name": "MyApp", "version": "1.1.0" },
    "features": ["auth", "billing"],
    "debug": true
  },
  "changed_keys": ["/app/version", "/debug", "/features"]
}

mode: patch (RFC 6902)

ParameterTypeRequiredDescription
modestringpatch
baseanyJSON value to patch
operationsarrayRFC 6902 operations (op, path, value?, from?)

Request example:

curl -X POST "https://api.thousand-api.com/v1/json/merge" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "patch",
    "base": { "name": "Alice", "tags": ["a"] },
    "operations": [
      { "op": "replace", "path": "/name", "value": "Bob" },
      { "op": "add", "path": "/tags/-", "value": "b" },
      { "op": "remove", "path": "/tags/0" }
    ]
  }'

Response example:

{
  "mode": "patch",
  "result": { "name": "Bob", "tags": ["b"] },
  "changed_keys": ["/name", "/tags/-", "/tags/0"]
}

Response fields

ParameterTypeDescription
modestringMode used (merge / patch)
resultanyResulting JSON after merge or patch
changed_keysstring[]Changed JSON Pointer paths (patch excludes test ops)

Array Diff

Compare two arrays and return added, removed, and unchanged elements. Supports primitive arrays (strings, numbers) and object arrays with a key field for ID-based comparison. Helps agents avoid manually comparing long lists, saving tokens and reducing errors. Each array may contain up to 1000 elements.

MCP tool: diff_arrays

POST /v1/array/diff

Parameters:

ParameterTypeRequiredDescription
beforearraySource array to compare from (max 1000 items)
afterarrayTarget array to compare to (max 1000 items)
keystring | null-Comparison key for object arrays (e.g. id, name). Omit or null for primitive comparison
ignore_orderboolean-When true, compare as sets ignoring order (default: false)

String array diff (key: null)

Request example:

curl -X POST "https://api.thousand-api.com/v1/array/diff" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "before": ["calendar", "cron", "scraper", "json"],
    "after": ["calendar", "cron", "scraper", "json", "template", "utilities"]
  }'

Response example:

{
  "added": ["template", "utilities"],
  "removed": [],
  "unchanged": ["calendar", "cron", "scraper", "json"],
  "reordered": false,
  "summary": "+2 -0 =4"
}

Object array diff (key: "id")

Request example:

curl -X POST "https://api.thousand-api.com/v1/array/diff" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "before": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}],
    "after": [{"id": 1, "name": "Alice"}, {"id": 3, "name": "Carol"}],
    "key": "id"
  }'

Response example:

{
  "added": [{"id": 3, "name": "Carol"}],
  "removed": [{"id": 2, "name": "Bob"}],
  "unchanged": [{"id": 1, "name": "Alice"}],
  "reordered": false,
  "summary": "+1 -1 =1"
}

Set comparison with ignore_order: true

Request example:

curl -X POST "https://api.thousand-api.com/v1/array/diff" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "before": ["a", "b", "c"],
    "after": ["b", "a", "c"],
    "ignore_order": true
  }'

Response example:

{
  "added": [],
  "removed": [],
  "unchanged": ["b", "a", "c"],
  "reordered": false,
  "summary": "+0 -0 =3"
}

Response fields

ParameterTypeDescription
addedarrayElements in after but not in before
removedarrayElements in before but not in after
unchangedarrayElements present in both (returned in after order)
reorderedbooleanWhen ignore_order is false, true if unchanged elements appear in a different order
summarystringDiff summary (e.g. +2 -0 =4)

JSONPath Query

Extract values from JSON data using JSONPath queries. Supports filter expressions and pairs well with validate_json.

MCP tool: query_json

POST /v1/json/query

Parameters:

ParameterTypeRequiredDescription
jsonanyJSON data to query (max 1MB)
querystringJSONPath query (must start with $)

Request example:

curl -X POST "https://api.thousand-api.com/v1/json/query" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "json": {
      "users": [
        {"name": "Alice", "age": 30},
        {"name": "Bob",   "age": 25}
      ]
    },
    "query": "$.users[*].name"
  }'

Response example:

{
  "query": "$.users[*].name",
  "result": ["Alice", "Bob"],
  "count": 2
}

JSONPath query examples:

CodeDescription
$.users[*].nameAll user names
$.users[0].emailFirst user's email
$.users[?(@.age > 25)].nameNames of users aged 26+
$..emailAll emails recursively at any depth

Numeric Statistics

Compute statistics (mean, median, standard deviation, percentiles, etc.) for a numeric array. No external libraries; up to 1000 elements.

MCP tool: calc_stats

POST /v1/math/stats

Parameters:

ParameterTypeRequiredDescription
valuesnumber[]Numeric array to analyze (max 1000 elements)

Request example:

curl -X POST "https://api.thousand-api.com/v1/math/stats" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"values": [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]}'

Response example:

{
  "count": 10,
  "sum": 550,
  "mean": 55,
  "median": 55,
  "mode": null,
  "min": 10,
  "max": 100,
  "range": 90,
  "variance": 825,
  "std_dev": 28.72,
  "percentiles": {
    "p25": 32.5,
    "p75": 77.5,
    "p90": 91,
    "p95": 95.5,
    "p99": 99.1
  }
}