# HN Feed Movement: Rank & Count Changes (`plainfeeds/hn-feed-movement`) Actor

Track exact rank, score and comment-count changes in an official Hacker News feed window. Before/after values, entry and exit, measured rates and explicit dead/deleted status. No comments or user profiles. One complete window per output row.

- **URL**: https://apify.com/plainfeeds/hn-feed-movement.md
- **Developed by:** [Paul Couach](https://apify.com/plainfeeds) (community)
- **Categories:** Developer tools, News, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 complete feed window delivereds

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

## HN Feed Movement

See how a Hacker News feed changes between scheduled runs: which items entered or left the first N positions, how far their ranks moved, and how their scores and comment counts changed. Every transition includes the exact previous and current values and the time between observations.

One dataset row contains the complete feed window and its exits. **$0.02 per delivered observation**, for a window of 1–100 items. There is no start fee. Unchanged checks in changes-only mode and upstream failures have no observation fee.

### Run a watch

Start with the default input:

```json
{
  "feed": "topstories",
  "windowSize": 10,
  "onlyChanges": false,
  "watchName": "default"
}
```

The result contains ten current items when the feed has at least ten IDs. Schedule repeated runs with the same settings to see movement. Set `onlyChanges` to `true` to deliver a row only when membership, rank, title, URL identity, score, comment count or API status changes. The first successful run always delivers.

Export the dataset as JSON to preserve nested before/after records. Apify schedules, run webhooks, Make and n8n can consume the dataset or its API endpoint. This tool does not send messages itself.

### Read the result

The outer row identifies the official `feed`, configured `windowSize`, actual `currentCount`, `previousCount`, `changedCount`, and feed retrieval times. `movements` contains each current item in feed order, followed by items that left the previous window.

| Field | Meaning |
| --- | --- |
| `changeType` | `initial`, `entered`, `changed`, `unchanged`, or `left_window` |
| `before`, `after` | Exact saved and current metadata: rank, type, API status, title, displayed URL, URL hash, score, comment count and retrieval time |
| `rankGain` | Previous rank minus current rank. Moving from 8 to 3 gives **+5**. Entry and exit have no numeric rank gain. |
| `scoreDelta`, `commentCountDelta` | Current count minus previous count, including negative changes. Missing values produce `null`. |
| `elapsedSeconds` | Seconds between this item's two retrieval times. First observations and nonpositive intervals produce `null`. |
| `scorePerHour`, `commentsPerHour` | Signed count delta divided by that interval, scaled to one hour. These describe observations, not individual votes or newly posted comments. |
| `changedFields` | Names of the metadata fields that differ. A query-only URL edit changes `urlHash`. |
| `hnUrl` | Link to the item's public discussion. No discussion or outbound page is fetched. |

For example, a made-up item moving from rank 8 to rank 3 with a score of 90 → 102 over 30 minutes has `rankGain: 5`, `scoreDelta: 12`, and `scorePerHour: 24`. This does not establish that exactly 12 people upvoted it.

`itemStatus` is `active`, `dead`, `deleted`, or `unavailable`. Dead and deleted require the API's explicit flags. An API JSON `null` means unavailable, with unknown metadata. If both flags are true, the displayed status is deleted. Optional counts stay unknown when missing, rather than becoming zero.

**Leaving the window does not mean deletion.** A `left_window` row has an `after.rank` of `null`. The tool fetches that item again and reports its separate API status and counts. It may still exist farther down the feed. An item that re-enters later is `entered`, without a reconstructed history of its time outside the window. An item entering and leaving between your scheduled checks can be missed entirely.

Top feeds can contain jobs and polls. They retain their positions and types; there is no hiring-text extraction. The tool reports the official API order, which can differ from the Hacker News HTML front page.

### Inputs and saved baselines

| Input | Default | Limits |
| --- | --- | --- |
| `feed` | `topstories` | `topstories`, `newstories`, `beststories`, `askstories`, `showstories` |
| `windowSize` | `10` | Integer, 1–100. Fixed fee for the complete window. |
| `onlyChanges` | `false` | Boolean. Off delivers repeat observations even if unchanged. |
| `watchName` | `default` | 1–40 letters, digits, hyphens or underscores |

Memory lives in the named `hn-feed-movement-state` key-value store in your Apify account. Each watch, feed and window size has a separate baseline. Changing feed or size starts an independent comparison; switching back resumes the earlier one. A new watch name starts fresh.

The tool validates the entire feed and every required current or exit item before delivering anything. HTTP errors, rate limits, robots denial, invalid responses and collection timeouts fail the run with a clear message and preserve the previous baseline. There is no proxy, alternate host, login or anti-blocking route. API requests start at least 100 milliseconds apart, with at most three item requests in flight.

The baseline advances only after the complete observation is pushed. A charging limit refusal leaves it eligible for the next run. Unchanged checks in changes-only mode also retain the last delivered baseline, so later rates span the interval since that delivery. `SUMMARY` records delivery status, request count and whether the baseline advanced. Failed runs have no result fee; Apify may still count platform use according to your account's rules.

Run one schedule at a time per watch. Dataset delivery and state saving are separate operations: a crash between them can cause a repeated observation on retry. If saving state fails, the run fails even if its row was already delivered. There is no exactly-once guarantee.

### Scope and limits

Data comes from the [official Hacker News API](https://github.com/HackerNews/API) on `hacker-news.firebaseio.com`. The API is a changing data structure: feed retrieval and individual item requests are not an atomic snapshot. Retrieval timestamps expose that interval. Rates from very short intervals can be noisy. This tool does not infer sentiment, predict virality or confirm a cause for rank/count changes.

No user profiles, author names, comment bodies, story text or contact details are stored or returned. Only the documented metadata fields are retained. Outbound URL query values are replaced with `[redacted]`, fragments are omitted, and a hash detects changes to the full published URL. The tool never follows those URLs. Titles and URL paths remain public source text and can contain names.

Responses are bounded to 1 MB each. API collection is limited to 180 seconds inside a 300-second Actor run. There is no retry through access denials or rate limits. An empty or malformed feed fails rather than fabricating exits.

This is an independent tool, unaffiliated with Hacker News, Y Combinator or Firebase. Use the Issues tab for bugs; replies are due within two days.

### Local verification

```sh
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pytest -q
```

Tests use original synthetic API responses and temporary fake storage, with no paid service. To read the real default feed locally, save `examples/INPUT.json` as `storage/key_value_stores/default/INPUT.json`, then run `.venv/bin/python -m src`.

# Actor input Schema

## `feed` (type: `string`):

Preserve the order returned by the official Firebase API. This is not a claim about the HTML front page.

## `windowSize` (type: `integer`):

First N IDs in the selected feed. All current items and exits share one output row and one $0.02 observation fee. Jobs and polls can appear in official feeds.

## `onlyChanges` (type: `boolean`):

First run always delivers. Later unchanged windows have no observation fee. Off returns one complete observation every successful run.

## `watchName` (type: `string`):

1–40 letters, digits, hyphens or underscores. Reuse for scheduled comparisons. Different feeds and window sizes have separate baselines. Run one schedule at a time per watch.

## Actor input object example

```json
{
  "feed": "topstories",
  "windowSize": 10,
  "onlyChanges": false,
  "watchName": "default"
}
```

# Actor output Schema

## `observations` (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 = {
    "feed": "topstories",
    "windowSize": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("plainfeeds/hn-feed-movement").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 = {
    "feed": "topstories",
    "windowSize": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("plainfeeds/hn-feed-movement").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 '{
  "feed": "topstories",
  "windowSize": 10
}' |
apify call plainfeeds/hn-feed-movement --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plainfeeds/hn-feed-movement"
        }
    }
}
```

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/nvSkhSig0ilvJzXsJ/builds/99livHRHRMH8VaIvi/openapi.json
