# Open API Contract Drift Monitor (`rustic_soybean/open-api-contract-drift-monitor`) Actor

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

## Pricing

from $2.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?

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

## OpenAPI Contract Drift Monitor

Monitor public OpenAPI or Swagger JSON specifications on a schedule. The first successful check establishes a baseline; later checks report operations, parameters, request and response schemas that changed. Results are structured for alerting, triage, and automated API-client maintenance.

### Why this complements endpoint health checks

An endpoint health check tells you whether a live URL responded and whether its observed JSON changed. This Actor watches the published contract itself: a removed operation, newly required request field, changed schema type, or removed response can be detected even before a client happens to call that path.

### Input

```json
{
  "specs": [
    { "name": "Petstore", "url": "https://petstore3.swagger.io/api/v3/openapi.json" }
  ],
  "monitorKey": "production-apis",
  "emitOnlyChanges": false
}
```

Use the same `monitorKey` and URL on recurring runs to compare against the Actor's private key-value-store baseline. The first successful run only creates a baseline. JSON OpenAPI 3.x and Swagger 2.0 documents are supported; YAML specifications are not currently supported. The URL is part of the baseline key, so changing the URL creates a new baseline.

### What is compared

- HTTP operation additions and removals.
- Operation IDs and deprecation status.
- Parameter names, locations, required flags, and schemas.
- Request-body required flags and JSON/media schemas.
- Response codes, headers, and schemas.
- Schema types, properties, required properties, enums, references, and common constraints.

Changes are classified as `BREAKING`, `POTENTIALLY_BREAKING`, or `NON_BREAKING`. Local JSON Pointer `$ref` values are expanded with a depth limit; remote `$ref` targets are not fetched. The classification is a review aid, not a formal compatibility proof: complex schema composition and version-specific semantics can be ambiguous, and consumers may depend on undocumented behavior. Always review the changed contract before releasing or rolling back a client.

### Cost and output controls

Each emitted dataset row represents one specification check. `emitOnlyChanges=true` suppresses successful unchanged rows while still updating the baseline; errors and initial baselines are still emitted. A `SUMMARY` key-value record contains run totals. The Actor does not call an LLM, use proxies, or require API credentials.

### Safety and limits

Only public HTTPS URLs are accepted. Credentials, private or reserved IP addresses, custom ports, and credential-like query parameters are rejected. Redirects are followed at most twice, with destination checks. Responses are capped at 2 MB and requests time out after at most 15 seconds. DNS checks are best-effort; do not treat this Actor as a network security boundary. It fetches specification documents only and does not call API operations or test their behavior.

The actor supports up to 20 URLs per run. Change output is capped at 100 entries per specification to bound dataset size. A successful fetch and valid document are required before a baseline is updated; fetch failures do not erase a prior baseline.

# Actor input Schema

## `specs` (type: `array`):

Monitor 1-20 public HTTPS OpenAPI or Swagger JSON specification URLs. YAML is not supported. No credentials or private endpoints.

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

Use the same name on scheduled runs to compare with the saved contract baseline.

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

When enabled, successful unchanged checks update the baseline without writing a dataset row.

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

Maximum time to wait for each specification download.

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

Maximum bytes accepted for one downloaded specification.

## Actor input object example

```json
{
  "specs": [
    {
      "name": "Petstore example",
      "url": "https://petstore3.swagger.io/api/v3/openapi.json"
    }
  ],
  "monitorKey": "default",
  "emitOnlyChanges": false,
  "timeoutMs": 8000,
  "maxResponseBytes": 1000000
}
```

# 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 = {
    "specs": [
        {
            "name": "Petstore example",
            "url": "https://petstore3.swagger.io/api/v3/openapi.json"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rustic_soybean/open-api-contract-drift-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 = { "specs": [{
            "name": "Petstore example",
            "url": "https://petstore3.swagger.io/api/v3/openapi.json",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("rustic_soybean/open-api-contract-drift-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 '{
  "specs": [
    {
      "name": "Petstore example",
      "url": "https://petstore3.swagger.io/api/v3/openapi.json"
    }
  ]
}' |
apify call rustic_soybean/open-api-contract-drift-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rustic_soybean/open-api-contract-drift-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/BjRwtY3omiL2xQevs/builds/otiLlfu4Yuge3tvyL/openapi.json
