# API Endpoint Health & JSON Schema Drift Monitor (`rustic_soybean/api-endpoint-contract-monitor`) Actor

Monitor public JSON APIs for downtime, latency, missing fields, and response-shape changes. Scheduled checks produce structured alerts for developers, data pipelines, and AI agents.

- **URL**: https://apify.com/rustic_soybean/api-endpoint-contract-monitor.md
- **Developed by:** [Chris Johnson](https://apify.com/rustic_soybean) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 api endpoint health 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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## API Endpoint Health & JSON Schema Drift Monitor

**Check public HTTP/JSON APIs for downtime, latency regressions, missing required fields, and unexpected response-shape changes.** Designed for developers, automation teams, data pipeline operators, and AI agents that rely on third-party APIs. This Actor runs one-off or on an Apify schedule and returns structured machine-readable health events.

### What this API monitor checks

Each run checks up to 20 public HTTP/HTTPS endpoints, measuring HTTP status and response time, validating JSON where requested, verifying configured JSON paths such as `data.items[0].id`, and fingerprinting a bounded JSON structure. Results include the HTTP status, latency, required-path failures, JSON validity, schema fingerprint, change type, and a timestamp. An endpoint is unhealthy if its expected status, JSON requirement, required fields, or latency threshold is not met.

The monitor stores a named baseline in its own Apify key-value store. A first check emits `INITIAL`. Later checks distinguish `RECOVERED`, `DEGRADED`, `STATUS_CHANGED`, `SCHEMA_CHANGED`, `CONTRACT_CHANGED`, and `UNCHANGED`. This is useful for detecting when a vendor silently removes an API field, when a service becomes slow, or when a workflow's upstream data source fails.

### Who uses it, and why checks recur

- **AI-agent operators:** verify public tools and JSON data sources before workflows depend on them.
- **Developers:** detect API status and shallow response-schema drift after vendor releases.
- **Data engineering teams:** monitor the external JSON paths consumed by ETL jobs.
- **Agencies and SaaS teams:** schedule recurring checks across customer integrations.
- **Compliance/operations teams:** keep an auditable dataset of periodic API checks.

These checks are valuable because APIs can change between deployments without warning. Schedule hourly or daily based on the impact of a failure. Apify schedules run the Actor; it is not a continuous daemon between scheduled runs.

### Example input

```json
{
  "endpoints": [
    {
      "name": "Apify Store API",
      "url": "https://api.apify.com/v2/store?limit=1",
      "expectedStatus": 200,
      "requiredJsonPaths": ["data.items"]
    }
  ],
  "monitorKey": "my-public-api-watchlist",
  "checkJson": true,
  "emitOnlyChanges": false,
  "latencyWarnMs": 3000,
  "timeoutMs": 8000
}
```

`emitOnlyChanges=false` (default) writes a dataset row for every endpoint check, including healthy unchanged checks, so a monitoring dashboard can show the latest status. Set it to `true` to emit only initial or changed events while still updating the baseline. Only emitted dataset rows trigger the proposed per-result charge; Apify may also apply a minimal run-start charge.

### Output and integrations

Use the default dataset for JSON/CSV export or consume results through the Apify API, webhooks, and supported automation integrations. The Actor also writes a `SUMMARY` record with counts of healthy, unhealthy, changed, and emitted checks. Output rows contain `name`, `url`, `httpStatus`, `expectedStatus`, `latencyMs`, `healthy`, `jsonValid`, `missingPaths`, `schemaFingerprint`, `changeType`, `changed`, `error`, and `checkedAt`.

### Safety, limits, and interpretation

Only **public, unauthenticated HTTP/HTTPS endpoints** are supported. Local, private, and reserved network addresses are blocked, as are credentials embedded in URLs and common API-key query parameters. Requests use GET and follow at most two redirects; each destination is checked. Responses are capped at 500 KB and time out after at most 15 seconds. The Actor does not send credentials or write to monitored endpoints.

A schema fingerprint compares a bounded sample of the response shape, not a complete OpenAPI or JSON Schema contract. Dynamic array shapes can cause expected changes, and a healthy result does not prove the endpoint is secure or correct. DNS rebinding defenses are best-effort; do not treat this as a network security boundary. This is operational monitoring, not penetration testing or an SLA guarantee.

### Pricing and cost control

The intended listing price is $0.002 per emitted endpoint-check dataset item ($2 per 1,000). A run with 10 endpoints emits up to 10 billable rows when `emitOnlyChanges=false`. Use `emitOnlyChanges=true` to pay only for initial/changed results and a small endpoint list for initial testing. No paid upstream Actors, residential proxies, or API subscriptions are required by the code. Platform compute and customer run limits still apply.

# Actor input Schema

## `endpoints` (type: `array`):

1-20 public HTTP/HTTPS API URLs. No authentication or private network endpoints.

## `monitorKey` (type: `string`):

Stable watchlist name used to persist the comparison baseline between scheduled runs.

## `checkJson` (type: `boolean`):

Require the response to parse as JSON before the endpoint can be healthy.

## `emitOnlyChanges` (type: `boolean`):

When enabled, unchanged checks update the baseline but do not write paid dataset rows.

## `latencyWarnMs` (type: `integer`):

Mark the endpoint unhealthy when response latency exceeds this threshold.

## `timeoutMs` (type: `integer`):

Maximum time to wait for each endpoint request before recording a failure.

## `maxResponseBytes` (type: `integer`):

Maximum response body size read for validation and schema fingerprinting.

## `concurrency` (type: `integer`):

Maximum number of endpoint checks performed at the same time.

## Actor input object example

```json
{
  "endpoints": [
    {
      "name": "Apify Store API",
      "url": "https://api.apify.com/v2/store?limit=1",
      "expectedStatus": 200,
      "requiredJsonPaths": [
        "data.items"
      ]
    }
  ],
  "monitorKey": "default",
  "checkJson": true,
  "emitOnlyChanges": false,
  "latencyWarnMs": 3000,
  "timeoutMs": 8000,
  "maxResponseBytes": 200000,
  "concurrency": 3
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "endpoints": [
        {
            "name": "Apify Store API",
            "url": "https://api.apify.com/v2/store?limit=1",
            "expectedStatus": 200,
            "requiredJsonPaths": [
                "data.items"
            ]
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rustic_soybean/api-endpoint-contract-monitor").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 = { "endpoints": [{
            "name": "Apify Store API",
            "url": "https://api.apify.com/v2/store?limit=1",
            "expectedStatus": 200,
            "requiredJsonPaths": ["data.items"],
        }] }

# Run the Actor and wait for it to finish
run = client.actor("rustic_soybean/api-endpoint-contract-monitor").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 '{
  "endpoints": [
    {
      "name": "Apify Store API",
      "url": "https://api.apify.com/v2/store?limit=1",
      "expectedStatus": 200,
      "requiredJsonPaths": [
        "data.items"
      ]
    }
  ]
}' |
apify call rustic_soybean/api-endpoint-contract-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rustic_soybean/api-endpoint-contract-monitor"
        }
    }
}
```

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/elrKcn2576j7rW9OR/builds/K2kaB01KR5ZdXWsQa/openapi.json
