# Url Uptime Checker (`eichan/url-uptime-checker`) Actor

- **URL**: https://apify.com/eichan/url-uptime-checker.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 88.2% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.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

## URL Uptime Checker

Snapshot **HTTP status and elapsed request time** for 1–10 public websites. It performs a single check per URL and writes one predictable Dataset record per URL. This Actor is for schedulable status snapshots, not an always-on monitor.

### Who it is for

Site owners, QA teams, automation builders, and small operations teams who want an exportable history of availability checks without accounts, the Apify SDK, or external API keys.

### Input example

```json
{
  "urls": ["https://example.com"],
  "timeoutSeconds": 10
}
```

| Field | Required | Meaning |
| --- | --- | --- |
| `urls` | Yes | 1–10 unique, public `http://` or `https://` addresses; the form prefills **one URL**. |
| `timeoutSeconds` | No | Time limit per request (2–30 seconds, default 10). Redirects and fallback can lengthen total run time. |

### Output example

One Dataset record per URL (illustrative values):

```json
{
  "url": "https://example.com",
  "statusCode": 200,
  "isUp": true,
  "responseTimeMs": 182,
  "error": null,
  "checkedAt": "2026-11-01T09:00:00Z"
}
```

- `statusCode`: final HTTP response status or `null` on network/TLS/protocol failure.
- `isUp`: `true` for final status 200–399, otherwise `false`. An HTTP 403/404/500 is not "up" under this rule.
- `responseTimeMs`: non-negative elapsed milliseconds for this check including redirects and possible fallback; this is **not** page load time.
- `error`: plain-language error, or `null` when up. For 4xx/5xx, includes the HTTP status code.
- `checkedAt`: identical UTC ISO 8601 timestamp across a run's records.

### How it works

1. Validates the public URLs. Only standard HTTP(S) ports 80 and 443 are supported.
2. Sends `HEAD` to avoid downloading the page. If the server returns **405 Method Not Allowed** or **501 Not Implemented**, retries once with `GET` and reads only one response byte.
3. Records the final HTTP status and elapsed time, even when a URL fails. A failed check is a Dataset row, not a traceback.
4. Writes rows to the run's default Apify Dataset through its platform-provided storage credentials, using `urllib` only.

### Scheduled use case

Schedule an hourly run against a small set of important endpoints. A downstream workflow can aggregate the `checkedAt`, `isUp`, and `responseTimeMs` rows over time and trigger alerts. **No alerts, previous-run comparisons, or persistence across runs are performed by this Actor.**

### Limits and cautions

- Public HTTP(S) endpoints only; no authentication, login, private network addresses, or arbitrary TCP ports. DNS results for requests must be public. The actor does not use Apify Proxy. DNS can change between validation and connection; do not treat this as a hardened network security boundary.
- Maximum 10 URLs; sequential checks; response time varies with server latency, redirects, and timeout. Redirects to private URLs are rejected.
- HEAD behavior may differ from GET; 403/405 and anti-bot restrictions can affect outcomes. A 200 response does not prove a healthy app.
- Malformed HTTP responses (including `BadStatusLine`) are handled as plain download errors with `statusCode: null`.
- Server-side redirects are followed; the final status, not every redirect, is reported. HTTP 300–399 responses left unresolved are classified as up by the defined HTTP rule.
- No billing calls, external API keys, scraping of protected pages, or continuous background monitoring.

### Run locally and verify

Provide a local input file at `storage/key_value_stores/default/INPUT.json` or set `ACTOR_INPUT_JSON` to the input JSON. From the Actor root:

```bash
python src/main.py
python -m unittest discover -s tests -p 'test_*.py' -v
python tests/smoke_run.py
```

Local output: `storage/datasets/default/000000001.json` (and later numbered files). `tests/smoke_run.py` launches a localhost fixture server, executes **`python src/main.py` as a real subprocess**, and prints both terminal output and the saved dataset item. For this isolated test only, it sets `EICHAN_TEST_LOOPBACK=1`; normal runs and all cloud runs deny loopback/private URLs. The fixture is not a substitute for a real external network/cloud build test.

### Deploy to Apify

Upload the **entire Actor folder**, build from the provided Dockerfile, and run it from the input form or schedule. The Apify runtime provides `APIFY_TOKEN`, `APIFY_DEFAULT_DATASET_ID`, and the input storage ID. These are **internal run credentials**, never supplied by the user; external API credentials are not required. The Actor calls Apify's Storage API using only Python's standard library.

### Store categories and suggested pricing

- **Category:** Automation (primary)
- **Secondary category:** Developer tools
- **Suggested pricing model:** Pay per event — a **per-run** `actor-start` event (provisional **$0.005 per run**). The small 1–10 URL workload makes run pricing straightforward. Adjust after reviewing cloud execution costs and customer demand.
- **Actual billing:** Not configured or charged. This code deliberately emits **no billable event**. Category placement and pricing must be set during future Store publication.

# Actor input Schema

## `urls` (type: `array`):

Small list of public web URLs; one URL is prefilled.

## `timeoutSeconds` (type: `integer`):

HEAD request timeout; GET fallback only if HEAD is unsupported.

## Actor input object example

```json
{
  "urls": [
    "https://example.com"
  ],
  "timeoutSeconds": 10
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# 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://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/url-uptime-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://example.com"] }

# Run the Actor and wait for it to finish
run = client.actor("eichan/url-uptime-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://example.com"
  ]
}' |
apify call eichan/url-uptime-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/url-uptime-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/ByHTcc7ImAgNbLZ8P/builds/t93xXD5BR9uH83pdI/openapi.json
