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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| json_str | string | ✓ | JSON string to parse and validate |
| schema | object | - | JSON Schema object (Draft-07). Omit to parse only |
| auto_repair | boolean | - | 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
| Parameter | Description |
|---|---|
| ipv4 | IPv4 address (private / loopback / multicast flags) |
| ipv6 | IPv6 address |
| cidr | CIDR notation (network and host count) |
| Email address (local / domain split) | |
| url | URL (http/https only) |
| credit_card | Credit card number (Luhn check and brand hint) |
| phone_jp | Japanese phone number |
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | string | ✓ | Value 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)
| Parameter | Type | Required | Description |
|---|---|---|---|
| mode | string | ✓ | merge or patch (default merge) |
| base | object | ✓ | Base JSON object to merge into |
| patch | object | ✓ | JSON object to merge |
| array_strategy | string | - | replace (overwrite) or concat (append). Default replace |
| null_overwrites | boolean | - | 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)
| Parameter | Type | Required | Description |
|---|---|---|---|
| mode | string | ✓ | patch |
| base | any | ✓ | JSON value to patch |
| operations | array | ✓ | RFC 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
| Parameter | Type | Description |
|---|---|---|
| mode | string | Mode used (merge / patch) |
| result | any | Resulting JSON after merge or patch |
| changed_keys | string[] | 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| before | array | ✓ | Source array to compare from (max 1000 items) |
| after | array | ✓ | Target array to compare to (max 1000 items) |
| key | string | null | - | Comparison key for object arrays (e.g. id, name). Omit or null for primitive comparison |
| ignore_order | boolean | - | 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
| Parameter | Type | Description |
|---|---|---|
| added | array | Elements in after but not in before |
| removed | array | Elements in before but not in after |
| unchanged | array | Elements present in both (returned in after order) |
| reordered | boolean | When ignore_order is false, true if unchanged elements appear in a different order |
| summary | string | Diff 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| json | any | ✓ | JSON data to query (max 1MB) |
| query | string | ✓ | JSONPath 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:
| Code | Description |
|---|---|
| $.users[*].name | All user names |
| $.users[0].email | First user's email |
| $.users[?(@.age > 25)].name | Names of users aged 26+ |
| All 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
| values | number[] | ✓ | 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
}
}