# CKAN & Socrata Schema Change Monitor (`mikelmyers/open-data-release-contract-monitor`) Actor

Monitor public CKAN and Socrata endpoints for schema drift, freshness, validation failures, and reproducible source receipts.

- **URL**: https://apify.com/mikelmyers/open-data-release-contract-monitor.md
- **Developed by:** [Mikel Myers](https://apify.com/mikelmyers) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$50.00 / 1,000 source checks

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

## CKAN & Socrata Schema Change Monitor

Detect broken or drifting government open-data feeds before they silently damage a report, integration, or archived snapshot.

This Actor checks bounded samples from explicit public CKAN and Socrata APIs and returns a source receipt for every endpoint. It is designed for scheduled monitoring, ETL checks, reproducibility records, and data-quality alerts.

### What each check reports

- `new`, `unchanged`, `changed`, `stale`, or `failed` state
- observed versus source-reported row counts, kept distinct
- required-field violations with affected sample indexes
- duplicate compound-key count
- added, removed, and type-changed fields
- newest observed source timestamp and freshness
- deterministic schema, sample, and raw-response SHA-256 hashes
- request URL, HTTP status, ETag, Last-Modified, and retrieval time

Baselines are preserved across scheduled runs in a named Apify key-value store. Use a unique `baselineStoreName` for each independent monitor configuration.

### Supported sources

#### Socrata

Provide a public domain and dataset ID such as `data.cityofnewyork.us` and `erm2-nwe9`. Optional query parameters may sort or filter the bounded sample. The Actor always enforces its own row cap.

#### CKAN

Provide an HTTPS CKAN action API base and either a package ID or search query. Package results are checked as tabular metadata records.

### Boundaries

- Public HTTPS APIs only.
- No passwords, private headers, cookies, login automation, CAPTCHA handling, or access-control bypass.
- Local, loopback, link-local, and private-IP destinations are rejected before HTTP fetch.
- Maximum 50 sources and 100 observed rows per source per run.
- A bounded sample is never described as a complete-dataset count.
- A successful request is not called healthy when it returns zero rows or lacks the configured freshness field; warnings remain explicit.

### Pricing

`$0.05` per `source-check` event. One event produces one source receipt, including an explicit failure receipt when a configured public endpoint returns an HTTP or validation error. Apify platform usage is included in the event price.

### Example input

```json
{
  "maxRows": 10,
  "baselineStoreName": "city-open-data-daily",
  "sources": [
    {
      "kind": "socrata",
      "domain": "data.cityofnewyork.us",
      "datasetId": "erm2-nwe9",
      "requiredFields": ["unique_key", "created_date"],
      "keyFields": ["unique_key"],
      "freshnessField": "created_date",
      "staleAfterHours": 168,
      "query": "$order=created_date DESC"
    }
  ]
}
```

### Interpreting results

The default dataset contains one receipt per checked endpoint. `changed` means the bounded canonical sample or inferred schema differs from the stored baseline; it does not prove that every row in the source changed. `failed` describes the observed request or validation failure and retains available response evidence.

This Actor reports source evidence and contract checks. It does not certify a dataset's legal completeness, accuracy, safety, or fitness for a regulated decision.

# Actor input Schema

## `maxRows` (type: `integer`):

Hard-capped at 100 by the Actor.

## `baselineStoreName` (type: `string`):

Named key-value store used to preserve source hashes and schemas across separate runs in this account.

## `sources` (type: `array`):

Each item must describe one explicit public CKAN or Socrata endpoint.

## Actor input object example

```json
{
  "maxRows": 100,
  "baselineStoreName": "open-data-contract-baselines",
  "sources": [
    {
      "kind": "socrata",
      "domain": "data.cityofnewyork.us",
      "datasetId": "erm2-nwe9",
      "requiredFields": [
        "unique_key",
        "created_date"
      ],
      "keyFields": [
        "unique_key"
      ],
      "freshnessField": "created_date",
      "staleAfterHours": 168,
      "query": "$order=created_date DESC"
    }
  ]
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("mikelmyers/open-data-release-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("mikelmyers/open-data-release-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 '{}' |
apify call mikelmyers/open-data-release-contract-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mikelmyers/open-data-release-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/6JNKqImjSRihtdLb3/builds/8dRPaNbmQmLaF2zm8/openapi.json
