# 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:** 1 total users, 0 monthly users, 95.8% 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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapeworks/json-content-checker"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tU4jsW8fgcj3R9whT/builds/hZYSos1UScWBj297X/openapi.json
