# API Test Runner — HTTP Checks, Assertions & Latency for Any API (`alauddinburki/api-test-runner`) Actor

Run a list of HTTP requests with assertions on status, timing, body, headers and JSON values; chain login → token → calls; p50/p95 latency; secrets never logged; private addresses refused. Schedule it as an API monitor.

- **URL**: https://apify.com/alauddinburki/api-test-runner.md
- **Developed by:** [Alauddin burki](https://apify.com/alauddinburki) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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

## API Test Runner — HTTP Checks, Assertions & Latency for Any API

Write your API checks once as a list of requests and expectations; run them on demand or **on a schedule as an API
monitor**. Each request is checked for **status, response time, body text, headers and JSON values**; values can be
**captured and reused** (log in → take the token → call the API); requests can be **repeated for p50/p95 latency**.
Every check is reported pass/fail with the reason.

### Safe by design

- **Secrets** (tokens, API keys) go in a secret field, are used as `{{NAME}}`, and are **masked everywhere** in the
  output and never logged.
- **Private, loopback and cloud-metadata addresses are refused** — also when a public URL redirects to one — so the
  Actor cannot be pointed at internal systems.

### Example

```json
{
  "requests": [
    { "name": "login", "method": "POST", "url": "https://api.example.com/login",
      "json": { "user": "monitor", "password": "{{PASSWORD}}" },
      "expect": { "status": 200, "json": [{ "path": "token", "exists": true }] },
      "capture": { "token": "token" } },
    { "name": "orders", "url": "https://api.example.com/orders?limit=5",
      "headers": { "authorization": "Bearer {{token}}" },
      "expect": { "status": 200, "maxMs": 800, "json": [{ "path": "items", "type": "array", "minLength": 1 }] } }
  ],
  "secrets": "PASSWORD=…",
  "repeat": 5
}
```

Assertions: `status` (one or a list), `maxMs`, `bodyContains`, `bodyNotContains`, `headers` (`name`, `contains`),
`json` (`path` with `equals`, `exists`, `type`, `minLength`, `matches`). Capture from `json.path`, `header:Name` or
`status`. Turn on `failRunOnFailure` so a scheduled run fails — and Apify alerts you — when an API breaks.

### Output

| Field | Example |
|---|---|
| `name`, `passed`, `status` | orders · true · 200 |
| `ms`, `p50Ms`, `p95Ms`, `runs` | 142 · 150 · 210 · 5 |
| `failedChecks` | `["status 404 — got 200"]` |
| `checks` | every assertion with its result |
| `error` | timeouts, network errors, refused addresses |
| `responseExcerpt` | first 500 characters, secrets masked |

### Pricing

Pay per result: **$0.0005 per row**. Plus a start fee of $0.0001 per GB of allocated memory (minimum one event).
One row is one request (all its repeats).

### Verification status (2026-11-11, local)

- ✅ 6 unit tests: JSON paths, templating, every assertion type, percentiles, the private-address guard (incl.
  169.254.169.254 and IPv6 local), redaction.
- ✅ Live (jsonplaceholder.typicode.com): list → capture → get, POST 201, an intentionally wrong expectation reported,
  metadata and localhost refused, an http→https redirect followed with each hop checked; the secret token appeared
  in neither the log nor the dataset; 0 schema mismatches.

# Actor input Schema

## `requests` (type: `array`):

In order. Each: name, method, url, headers, json or body, expect {status, maxMs, bodyContains, bodyNotContains, headers \[{name, contains}], json \[{path, equals|exists|type|minLength|matches}]}, capture {varName: "json.path" | "header:Name" | "status"}. Use {{varName}} or {{SECRET}} anywhere.

## `secrets` (type: `string`):

NAME=value lines or a JSON object; use as {{NAME}}. Never logged or output.

## `repeat` (type: `integer`):

For latency percentiles (p50, p95).

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

Per request.

## `stopOnFailure` (type: `boolean`):

Useful for dependent chains.

## `failRunOnFailure` (type: `boolean`):

So schedules, webhooks and CI can alert on it.

## Actor input object example

```json
{
  "requests": [
    {
      "name": "list posts",
      "url": "https://jsonplaceholder.typicode.com/posts?userId=1",
      "expect": {
        "status": 200,
        "maxMs": 3000,
        "json": [
          {
            "path": "[0].userId",
            "equals": 1
          },
          {
            "path": "",
            "type": "array",
            "minLength": 5
          }
        ]
      },
      "capture": {
        "postId": "[0].id"
      }
    },
    {
      "name": "get first post",
      "url": "https://jsonplaceholder.typicode.com/posts/{{postId}}",
      "expect": {
        "status": 200,
        "json": [
          {
            "path": "id",
            "equals": 1
          }
        ]
      }
    }
  ],
  "repeat": 1,
  "timeoutSecs": 30,
  "stopOnFailure": false,
  "failRunOnFailure": false
}
```

# Actor output Schema

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

Every row of the run, in the dataset (fields as listed under Output in the README).

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

Counts, items not found and other notes for the run.

# 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 = {
    "requests": [
        {
            "name": "list posts",
            "url": "https://jsonplaceholder.typicode.com/posts?userId=1",
            "expect": {
                "status": 200,
                "maxMs": 3000,
                "json": [
                    {
                        "path": "[0].userId",
                        "equals": 1
                    },
                    {
                        "path": "",
                        "type": "array",
                        "minLength": 5
                    }
                ]
            },
            "capture": {
                "postId": "[0].id"
            }
        },
        {
            "name": "get first post",
            "url": "https://jsonplaceholder.typicode.com/posts/{{postId}}",
            "expect": {
                "status": 200,
                "json": [
                    {
                        "path": "id",
                        "equals": 1
                    }
                ]
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("alauddinburki/api-test-runner").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 = { "requests": [
        {
            "name": "list posts",
            "url": "https://jsonplaceholder.typicode.com/posts?userId=1",
            "expect": {
                "status": 200,
                "maxMs": 3000,
                "json": [
                    {
                        "path": "[0].userId",
                        "equals": 1,
                    },
                    {
                        "path": "",
                        "type": "array",
                        "minLength": 5,
                    },
                ],
            },
            "capture": { "postId": "[0].id" },
        },
        {
            "name": "get first post",
            "url": "https://jsonplaceholder.typicode.com/posts/{{postId}}",
            "expect": {
                "status": 200,
                "json": [{
                        "path": "id",
                        "equals": 1,
                    }],
            },
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("alauddinburki/api-test-runner").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 '{
  "requests": [
    {
      "name": "list posts",
      "url": "https://jsonplaceholder.typicode.com/posts?userId=1",
      "expect": {
        "status": 200,
        "maxMs": 3000,
        "json": [
          {
            "path": "[0].userId",
            "equals": 1
          },
          {
            "path": "",
            "type": "array",
            "minLength": 5
          }
        ]
      },
      "capture": {
        "postId": "[0].id"
      }
    },
    {
      "name": "get first post",
      "url": "https://jsonplaceholder.typicode.com/posts/{{postId}}",
      "expect": {
        "status": 200,
        "json": [
          {
            "path": "id",
            "equals": 1
          }
        ]
      }
    }
  ]
}' |
apify call alauddinburki/api-test-runner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alauddinburki/api-test-runner"
        }
    }
}
```

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/6ZteCuGPXAsBfUFn7/builds/BXTlQikeWk3phpZgN/openapi.json
