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: data.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.

POST /v1/json/validate-schema

Unlike data.validate_json, validates already-parsed JSON data against JSON Schema (Draft-07) with full constraint support (format, pattern, min/max, additionalProperties, etc.). No auto-repair. Errors include path, message, and schema_path.

MCP tool: data.validate_schema

Parameters:

ParameterTypeRequiredDescription
dataanyJSON data to validate (null is a valid value)
schemaobjectJSON Schema object (Draft-07)
all_errorsboolean-Return all errors (default false: first error only)

Request example:

curl -X POST https://api.thousand-api.com/v1/json/validate-schema \
  -H "x-api-key: YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "data": { "name": "Alice", "age": -1, "email": "not-an-email" },
    "schema": {
      "type": "object",
      "required": ["name", "age", "email"],
      "properties": {
        "name": { "type": "string" },
        "age": { "type": "number", "minimum": 0 },
        "email": { "type": "string", "format": "email" }
      }
    },
    "all_errors": true
  }'

Response example:

{
  "valid": false,
  "error_count": 2,
  "errors": [
    {
      "path": "/age",
      "message": "must be >= 0",
      "schema_path": "#/properties/age/minimum"
    },
    {
      "path": "/email",
      "message": "must match format \"email\"",
      "schema_path": "#/properties/email/format"
    }
  ]
}

Response:

HTTP 200 even when valid is false. Invalid schema returns HTTP 400 (schema is not a valid JSON Schema: ...). Request body max 1MB.

Unified Validation

Run JSON, UUID, Luhn, or barcode validation by specifying a single type. Reuses the same shared logic as data.validate_json and related individual tools.

MCP tool: data.validate_all (unified alternative to data.validate_json / security.validate_uuid / security.validate_luhn / security.validate_barcode)

POST /v1/validate/all

Parameters:

ParameterTypeRequiredDescription
typestringjson / uuid / luhn / barcode
valuestringValue to validate
optionsobject-Type-specific extra parameters

Request example:

curl -X POST "https://api.thousand-api.com/v1/validate/all" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "json",
    "value": "{\"name\":\"Alice\"}"
  }'

Response example:

{
  "type": "json",
  "valid": true,
  "details": {
    "json": { "name": "Alice" },
    "repaired": false
  }
}

Format Validation

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

MCP tool: data.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: data.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: data.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)

Sort JSON Arrays

Sorts an array of JSON objects by one or more keys, with independent ascending/descending order per key. LLMs often get multi-key comparator logic (such as Array.sort compare functions) wrong; this API provides a reliable stable sort instead. Key paths support dot notation (profile.age) and array indexes (items[0].name). Up to 1000 elements per request.

MCP tool: data.sort_json

POST /v1/data/sort

Parameters:

ParameterTypeRequiredDescription
itemsarrayArray of JSON objects to sort (max 1000 elements)
sort_keysarraySort keys (1 or more). Earlier keys take precedence; later keys break ties
sort_keys[].keystringDot-notation key path (e.g. age, profile.age, items[0].name)
sort_keys[].orderstringasc (ascending) or desc (descending)

Single-key sort (age ascending)

Request example:

curl -X POST "https://api.thousand-api.com/v1/data/sort" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"name": "Alice", "age": 30},
      {"name": "Bob", "age": 25}
    ],
    "sort_keys": [{"key": "age", "order": "asc"}]
  }'

Response example:

{
  "sorted": [
    {"name": "Bob", "age": 25},
    {"name": "Alice", "age": 30}
  ],
  "count": 2
}

Multi-key sort (age ascending, then name descending for ties)

Request example:

curl -X POST "https://api.thousand-api.com/v1/data/sort" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"name": "Alice", "age": 30},
      {"name": "Bob", "age": 25},
      {"name": "Carol", "age": 30}
    ],
    "sort_keys": [
      {"key": "age", "order": "asc"},
      {"key": "name", "order": "desc"}
    ]
  }'

Response example:

{
  "sorted": [
    {"name": "Bob", "age": 25},
    {"name": "Carol", "age": 30},
    {"name": "Alice", "age": 30}
  ],
  "count": 3
}

Response fields

ParameterTypeDescription
sortedarraySorted array (stable sort; equal elements keep their original order)
countintegerNumber of elements in the sorted array

JSONPath Query

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

MCP tool: data.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: data.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
  }
}