# Feed Autodiscovery, Self-Link, and Serving-Header Publish Gate (`kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate`) Actor

Checks that each site advertises its RSS, Atom, or JSON feed, that the feed resolves and is served correctly, and that it points back to the site.

- **URL**: https://apify.com/kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 site checkeds

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

## Feed Autodiscovery, Self-Link, and Serving-Header Publish Gate

This Actor is a stateless gate for feed publishers. Run it before and after a site deploy.
It checks the path from the HTML page to the feed, not only the feed body.

### What it checks

For each site, the Actor runs these checks. You can select a subset with `checks`.

| Check | What it does | Reason codes |
| --- | --- | --- |
| `discovery` | Reads `<link rel="alternate">` in the page. Feed types: RSS, Atom, JSON. | `SITE_UNREACHABLE`, `SITE_HTTP_ERROR`, `NO_FEED_DISCOVERED`, `FEED_NOT_ADVERTISED`, `BLOCKED_TARGET` |
| `feed_status` | Fetches each feed. Records the HTTP status and the redirect chain. | `FEED_UNREACHABLE`, `FEED_HTTP_ERROR`, `TOO_MANY_REDIRECTS`, `FEED_TOO_LARGE`, `BLOCKED_TARGET` |
| `content_type` | Compares the served `Content-Type` with the detected format. | `CONTENT_TYPE_MISSING`, `CONTENT_TYPE_MISMATCH` |
| `format` | Detects RSS 2.0, Atom 1.0, or JSON Feed 1.0/1.1. | `FORMAT_UNKNOWN` |
| `self_link` | Compares `atom:link rel="self"` (or `feed_url`) with the final fetched URL. | `SELF_LINK_MISSING`, `SELF_LINK_MISMATCH` |
| `home_link` | Compares the channel/home link host with the site host. `www.` is ignored. | `HOME_LINK_MISSING`, `HOME_HOST_MISMATCH` |
| `item_backlinks` | Fetches up to 5 item pages (HTML head only). Checks that each page advertises the feed. | `ITEM_UNREACHABLE`, `ITEM_NO_BACKLINK` |

Each failed check has one reason code for each feed.
A check that did not run has the state `skipped`.

Accepted `Content-Type` values: RSS: `application/rss+xml`, `application/xml`, `text/xml`.
Atom: `application/atom+xml`, `application/xml`, `text/xml`.
JSON Feed: `application/feed+json`, `application/json`.

### Input

| Field | Default | Notes |
| --- | --- | --- |
| `sites` | 2 public sites | 1 to 100 public http(s) URLs. The Actor removes duplicates. |
| `feedUrls` | `{}` | Map of site URL to at most 2 explicit feed URLs. |
| `checks` | all | Subset of the check names above. |
| `maxConcurrency` | 5 | 1 to 10. |
| `requestTimeoutSecs` | 15 | 3 to 60. |

An empty input `{}` runs with the defaults and succeeds.

### Output

One dataset row for each site. Main fields:
`site_url`, `final_site_url`, `site_status`, `discovered_feeds`, `feeds`, `checks`,
`failures`, `passed`.
Each entry in `feeds` has the feed URL, HTTP status, redirect chain, `content_type`, `format`,
self-link data, home-link data, and `sampled_items`.
Each entry in `failures` has `check`, `code`, and `feed_url`.

A failed gate is a normal result. The run still ends as SUCCEEDED.
Read `passed` in the dataset to decide whether your CI (continuous integration) job passes.
The status message shows the totals.
The run fails only for a real malfunction of the Actor.

### Limits and safety

- 1 MB per HTML page. 2 feeds per site. 2 MB per feed. 5 item pages per feed.
  The Actor reads at most 256 KB of each item page.
- At most 5 redirects for each request.
- The Actor uses HTTP only. It does not run a browser.
- The Actor rejects private, loopback, link-local, and reserved addresses.
  It checks the address of every redirect hop. Only ports 80 and 443 are allowed.
- The Actor refuses feeds that contain a DTD (document type definition) or entity declarations.
  These feeds get `FORMAT_UNKNOWN`.
- Known limit: the address check and the connection use two separate DNS lookups.
  A hostile DNS server could change its answer between them.

### Pricing (pay-per-event)

The Actor calls `Actor.charge` for one event: `site-checked`.
It charges once for each site checked. One event covers up to 2 feeds and 10 sampled item pages.
The Actor does not charge for a site that has an invalid URL, a blocked private target,
or an internal error. It charges for a site whose target is down, because it did check that site.
The Actor stops when the charge limit is reached. The status message says so.

The pricing proposal is $0.004 for each `site-checked` event. Set the price in the Apify Console.
This repository does not change pricing.

### Development

```
uv run pytest
uv run ruff check .
```

Local run: `apify run` with `.actor/default_input.json`.

# Actor input Schema

## `sites` (type: `array`):

1 to 100 public http(s) site URLs. Each site is one billed check.

## `feedUrls` (type: `object`):

Map of site URL to a list of at most 2 feed URLs. If a site has an entry, the Actor checks these feeds and reports any feed that the site page does not advertise.

## `checks` (type: `array`):

Names of the checks to run. Default: all checks.

## `maxConcurrency` (type: `integer`):

How many sites the Actor checks at the same time.

## `requestTimeoutSecs` (type: `integer`):

Timeout for each HTTP request.

## Actor input object example

```json
{
  "sites": [
    "https://daringfireball.net/",
    "https://www.python.org/"
  ],
  "feedUrls": {},
  "checks": [
    "discovery",
    "feed_status",
    "content_type",
    "format",
    "self_link",
    "home_link",
    "item_backlinks"
  ],
  "maxConcurrency": 5,
  "requestTimeoutSecs": 15
}
```

# Actor output Schema

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

Dataset rows with the verdict for each site.

# 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 = {
    "sites": [
        "https://daringfireball.net/",
        "https://www.python.org/"
    ],
    "feedUrls": {},
    "checks": [
        "discovery",
        "feed_status",
        "content_type",
        "format",
        "self_link",
        "home_link",
        "item_backlinks"
    ],
    "maxConcurrency": 5,
    "requestTimeoutSecs": 15
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate").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 = {
    "sites": [
        "https://daringfireball.net/",
        "https://www.python.org/",
    ],
    "feedUrls": {},
    "checks": [
        "discovery",
        "feed_status",
        "content_type",
        "format",
        "self_link",
        "home_link",
        "item_backlinks",
    ],
    "maxConcurrency": 5,
    "requestTimeoutSecs": 15,
}

# Run the Actor and wait for it to finish
run = client.actor("kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate").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 '{
  "sites": [
    "https://daringfireball.net/",
    "https://www.python.org/"
  ],
  "feedUrls": {},
  "checks": [
    "discovery",
    "feed_status",
    "content_type",
    "format",
    "self_link",
    "home_link",
    "item_backlinks"
  ],
  "maxConcurrency": 5,
  "requestTimeoutSecs": 15
}' |
apify call kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/feed-autodiscovery-self-link-and-serving-header-publish-gate"
        }
    }
}
```

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/8afocWiyg4v3nuYZC/builds/gEi0IEXbLXngT8fxs/openapi.json
