# JSON Content Checker (`scrapeworks/json-content-checker`) Actor

Check and validate a list of JSON URLs or API endpoints in bulk: confirm each response is valid JSON, inspect its structure, assert that required fields and values are present, and get a stable content hash to detect when a feed changes.

- **URL**: https://apify.com/scrapeworks/json-content-checker.md
- **Developed by:** [Nicolas van Arkens](https://apify.com/scrapeworks) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## JSON Content Checker

Fetch any list of JSON endpoints or `.json` files and get a clean, structured **check** of each one — is it valid JSON, what's its shape, has it changed, and do the values you expect actually hold? Built for **bulk**: pass one URL or a thousand, and every URL becomes one check record. No API key required (optional custom headers let you check protected endpoints).

### What it's for

- **API & endpoint monitoring** — confirm a JSON API still returns `200` and valid JSON on a schedule, and catch the moment it breaks.
- **Change detection** — every record includes a stable `contentHash`. Diff the hash across scheduled runs to know instantly when a feed's content changed.
- **Data-contract / schema checks** — assert that required paths exist (`data.results`, `meta.total`) and that values are in range (`data.total > 100`, `status == "ok"`) across many endpoints at once.
- **Bulk QA & pipelines** — validate a whole list of JSON files or microservice responses in one run and export clean JSON for your dashboards.

### Input

| Field | Type | Description |
|-------|------|-------------|
| `urls` | array | JSON endpoints / `.json` URLs to check. A missing scheme defaults to `https://`. Each URL produces one record. |
| `requiredPaths` | array | *Optional.* Dot/bracket paths that must exist in each document, e.g. `data.results`, `items[0].id`. Reported as present/missing with type + preview. |
| `expectations` | array | *Optional.* Value assertions, e.g. `status == "ok"`, `data.total > 100`, `items contains "foo"`, `meta.next missing`. Each is reported as passed/failed with the actual value. |
| `requestHeaders` | object | *Optional.* Extra HTTP headers sent with every request (e.g. an `Authorization` token for protected JSON). |
| `followRedirects` | boolean | Follow redirects and check the final destination. Default `true`. |
| `timeoutSecs` | integer | Per-request timeout in seconds. Default `30`. |
| `maxResults` | integer | Safety cap on URLs checked per run. Default `1000`. |

#### Expectation syntax

One assertion per entry. The left side is a path; the right side a JSON literal (number, `"string"`, `true`/`false`/`null`).

````

status == "ok"          data.total > 100        items\[0].id exists
version != "0"          meta.count <= 50        results missing
title contains "Report" tags contains "news"    data.ok == true

````

Supported operators: `exists`, `missing` / `present`, `==`, `!=`, `>`, `<`, `>=`, `<=`, `contains`.

### Output

One record per URL:

```json
{
  "url": "https://jsonplaceholder.typicode.com/todos/1",
  "finalUrl": "https://jsonplaceholder.typicode.com/todos/1",
  "success": true,
  "statusCode": 200,
  "contentType": "application/json; charset=utf-8",
  "declaredJson": true,
  "validJson": true,
  "jsonError": null,
  "rootType": "object",
  "topLevelKeys": ["userId", "id", "title", "completed"],
  "topLevelKeyCount": 4,
  "arrayLength": null,
  "itemCount": 4,
  "sizeBytes": 83,
  "depth": 1,
  "contentHash": "sha256:8e3f...c1",
  "hashMode": "canonical-json",
  "pathChecks": [
    { "path": "title", "exists": true, "type": "string", "valuePreview": "\"delectus aut autem\"" }
  ],
  "expectationResults": [
    { "expression": "id == 1", "path": "id", "operator": "==", "expected": 1, "actual": 1, "passed": true }
  ],
  "checksPassed": 2,
  "checksTotal": 2,
  "allChecksPassed": true,
  "fetchedAt": "2026-06-14T00:00:00+00:00",
  "error": null
}
````

### How the content hash works

For valid JSON, `contentHash` is a SHA-256 of the **canonicalized** document (keys sorted, whitespace removed), so cosmetic reordering or reformatting never registers as a change — only real content does. For non-JSON responses, the hash falls back to the raw bytes (`hashMode: "raw-bytes"`). Run the actor on a schedule and compare `contentHash` between runs to detect when a feed actually changed.

### Notes

- A non-JSON response is **not** an error — it's a real result: `validJson` is `false`, `jsonError` explains why, and the row is still returned (and charged).
- A URL that fails to fetch (timeout, DNS error, connection refused, bad URL) is recorded with `success: false` and the reason — it never crashes the run and is **never charged**.
- Paths support dot and bracket notation, including array indices (`items[0].id`) and quoted keys (`data["weird.key"]`).
- `topLevelKeys` is capped at the first 100 keys for very wide objects; `topLevelKeyCount` always reflects the true total.

# Actor input Schema

## `urls` (type: `array`):

List of JSON endpoints or .json file URLs to fetch and check. A missing scheme defaults to https://. Each URL produces one check record. Pass as many as you like — the actor checks them all in one run.

## `requiredPaths` (type: `array`):

Optional. Dot/bracket paths that must be present in each JSON document, e.g. "data.results", "meta.total", "items\[0].id". For every path you get back whether it exists, its type, and a value preview. Applied to every URL.

## `expectations` (type: `array`):

Optional. One assertion per line, evaluated against each JSON document. Supports: "path exists", "path missing", "path == value", "!=", ">", "<", ">=", "<=", and "path contains value". Values may be JSON literals, e.g. status == "ok", data.total > 100, items contains "foo". Each assertion reports passed/failed with the actual value.

## `requestHeaders` (type: `object`):

Optional HTTP headers sent with every request, e.g. an Authorization token or API key for protected JSON endpoints. Example: {"Authorization": "Bearer XXX"}.

## `followRedirects` (type: `boolean`):

If enabled, follows redirects and checks the final destination. If disabled, checks the first response as-is.

## `timeoutSecs` (type: `integer`):

How long to wait for each URL before recording it as a failed fetch.

## `maxResults` (type: `integer`):

Safety cap on how many URLs are checked in one run. Extra URLs beyond this are skipped.

## Actor input object example

```json
{
  "urls": [
    "https://jsonplaceholder.typicode.com/todos/1",
    "https://jsonplaceholder.typicode.com/users",
    "https://api.github.com/repos/apify/apify-sdk-python"
  ],
  "requiredPaths": [],
  "expectations": [],
  "requestHeaders": {},
  "followRedirects": true,
  "timeoutSecs": 30,
  "maxResults": 1000
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://jsonplaceholder.typicode.com/todos/1",
        "https://jsonplaceholder.typicode.com/users",
        "https://api.github.com/repos/apify/apify-sdk-python"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapeworks/json-content-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [
        "https://jsonplaceholder.typicode.com/todos/1",
        "https://jsonplaceholder.typicode.com/users",
        "https://api.github.com/repos/apify/apify-sdk-python",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("scrapeworks/json-content-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://jsonplaceholder.typicode.com/todos/1",
    "https://jsonplaceholder.typicode.com/users",
    "https://api.github.com/repos/apify/apify-sdk-python"
  ]
}' |
apify call scrapeworks/json-content-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapeworks/json-content-checker",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "JSON Content Checker",
        "description": "Check and validate a list of JSON URLs or API endpoints in bulk: confirm each response is valid JSON, inspect its structure, assert that required fields and values are present, and get a stable content hash to detect when a feed changes.",
        "version": "0.1",
        "x-build-id": "hZYSos1UScWBj297X"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapeworks~json-content-checker/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapeworks-json-content-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/scrapeworks~json-content-checker/runs": {
            "post": {
                "operationId": "runs-sync-scrapeworks-json-content-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/scrapeworks~json-content-checker/run-sync": {
            "post": {
                "operationId": "run-sync-scrapeworks-json-content-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "urls": {
                        "title": "JSON URLs to check",
                        "type": "array",
                        "description": "List of JSON endpoints or .json file URLs to fetch and check. A missing scheme defaults to https://. Each URL produces one check record. Pass as many as you like — the actor checks them all in one run.",
                        "default": [
                            "https://jsonplaceholder.typicode.com/todos/1",
                            "https://jsonplaceholder.typicode.com/users",
                            "https://api.github.com/repos/apify/apify-sdk-python"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "requiredPaths": {
                        "title": "Required paths (must exist)",
                        "type": "array",
                        "description": "Optional. Dot/bracket paths that must be present in each JSON document, e.g. \"data.results\", \"meta.total\", \"items[0].id\". For every path you get back whether it exists, its type, and a value preview. Applied to every URL.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "expectations": {
                        "title": "Value expectations (assertions)",
                        "type": "array",
                        "description": "Optional. One assertion per line, evaluated against each JSON document. Supports: \"path exists\", \"path missing\", \"path == value\", \"!=\", \">\", \"<\", \">=\", \"<=\", and \"path contains value\". Values may be JSON literals, e.g. status == \"ok\", data.total > 100, items contains \"foo\". Each assertion reports passed/failed with the actual value.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "requestHeaders": {
                        "title": "Extra request headers",
                        "type": "object",
                        "description": "Optional HTTP headers sent with every request, e.g. an Authorization token or API key for protected JSON endpoints. Example: {\"Authorization\": \"Bearer XXX\"}.",
                        "default": {}
                    },
                    "followRedirects": {
                        "title": "Follow redirects",
                        "type": "boolean",
                        "description": "If enabled, follows redirects and checks the final destination. If disabled, checks the first response as-is.",
                        "default": true
                    },
                    "timeoutSecs": {
                        "title": "Request timeout (seconds)",
                        "minimum": 1,
                        "maximum": 300,
                        "type": "integer",
                        "description": "How long to wait for each URL before recording it as a failed fetch.",
                        "default": 30
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Safety cap on how many URLs are checked in one run. Extra URLs beyond this are skipped.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
