# Hacker News Story & Comment Tree Export (`jpmarketdata/hacker-news-story-comment-tree-export`) Actor

Export exact Hacker News stories and ranked feed discussions with authored reply trees, parent IDs, depth, source times and honest truncation coverage. Includes up to 500 comments per thread; no author profiles or keyword-history claims.

- **URL**: https://apify.com/jpmarketdata/hacker-news-story-comment-tree-export.md
- **Developed by:** [h ichi](https://apify.com/jpmarketdata) (community)
- **Categories:** Automation, Developer tools, Marketing
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 discussion thread exporteds

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

## Hacker News Story & Comment Tree Export

Export exact Hacker News discussions or ranked Top/Show/Ask/New/Best/Job feed threads with their bounded authored reply trees. Use parent IDs, reply depth, sibling order and source timestamps to analyze developer feedback without matching a story by a loose search phrase.

### Input

Default: Top and Show feeds, up to 5 valid threads, 50 candidate IDs per feed, 500 comment nodes per thread, depth20 and 800 total requests. Empty feeds plus storyIds/storyUrls select exact discussions. Global caps and interleaving preserve source coverage. This Actor does not provide Algolia keyword history, user profiles, external article crawling or alert delivery.

### Output

One story_thread row contains story identity/title/date, observed score and the flattened ordered comment tree. Each comment identifies its parent, depth and siblingIndex. Deleted/dead nodes can remain as hierarchy anchors without text. Unknown optional facts are omitted and reported in availability. coverage states complete/incomplete, node limits, pending children and source observation. An evolving discussion is not an atomic snapshot.

### Price

$0.004 per unique delivered thread includes its bounded reply tree. There is no start or per-comment add-on. At least one nonempty authored readable comment, source story identity/title/date and valid parent relationships are required. Empty, dead, metadata-only, duplicate, excluded and failed source results are not charged. Default cap$0.02; maximum10thread cap$0.04. Source user-selected limits can deliver a clearly marked partial tree, while an upstream error fails before delivery.

### Failure and empty results

All source/auth/robots failures fail the run;429 is rate-limit, invalid item/tree structure is structure-change, timeout remains timeout. No automatic retries: transient responses and timeouts fail before output; no follow-up request after429. Missing/deleted roots are skipped, but a successful run with no valid thread is an explicit no-matching-results failure. No empty success or billed metadata summary.

### Privacy and source boundaries

Only official public Firebase JSON endpoints are accessed; robots is checked first and redirects are restricted to that exact HTTPS host. No API key, login, cookies or private endpoint input. Author handles, avatars, emails, phones and profile data are excluded. Contact strings embedded in text are redacted; incidental self-disclosure may remain, so output is not claimed perfectly anonymous. Fixtures use synthetic text. No external article/user links are followed.

### Source and reliability

Uses the official Hacker News API. Source terms include restrictions on commercial copying and automated extraction, recorded in the current scout underDR-0007; native API availability is not a resale license. Data may change during collection. Cloud cost, row/event PPE parity and final independent review are release gates, not claims based on local fixtures.

### Limits

Hard maximum1000requests,10threads,500comment nodes per thread anddepth20. Acquisition is bounded to240s within a300s Actor timeout at256MB. At most5 requests run concurrently with at least0.1s between starts, applicable robots delays and30s HTTP timeout. Stream limits are2MiB wire/decoded per response,32MiB cumulative wire/decoded and16MiB staged output. Size breaches fail before delivery. A declared acquisition deadline returns honest pending-node coverage; upstream timeout remains failure. All selected feeds/root candidates are discovered before round-robin reply expansion. The entire positive output is staged and checked against the event allowance before SDK charged delivery. Default5threads/800requests can be incomplete for large discussions; coverage never claims full history when a bound is reached.

# Actor input Schema

## `feeds` (type: `array`):

Up to six official feeds. Empty selects direct story inputs only. Source order is retained and feeds are interleaved; keyword/user/profile search is outside this contract. $0.004 per delivered discussion thread.

## `storyIds` (type: `array`):

Up to 20 exact positive story IDs. A story URL contains its ID after item?id=. Direct selections avoid ambiguous keyword matches. $0.004 per delivered discussion thread.

## `storyUrls` (type: `array`):

Up to 20 HTTPS news.ycombinator.com/item?id=NUMBER links. Only the ID is used; acquisition stays on the official Firebase JSON host. $0.004 per delivered discussion thread.

## `maxStories` (type: `integer`):

Global unique paid thread cap. $0.004 per delivered thread includes its bounded reply tree; empty/duplicate/failed threads have no event. $0.004 per delivered discussion thread.

## `maxFeedItems` (type: `integer`):

Maximum ranked source IDs considered per feed, including skipped empty/dead items. The official feed array is bounded at the source; this is a prefix, not keyword search. $0.004 per delivered discussion thread.

## `maxCommentsPerStory` (type: `integer`):

Bound on comment nodes including deleted/dead anchors. Up to 500 comments are included in the thread fee; limits are visible in coverage. $0.004 per delivered discussion thread.

## `maxDepth` (type: `integer`):

Root story is depth zero. Replies deeper than this bound are not included; coverage marks the thread incomplete. Public source sibling order is preserved. $0.004 per delivered discussion thread.

## `maxRequests` (type: `integer`):

Global attempts including robots, feed arrays, items and retries. Charges ($) apply only to valid delivered threads. Explicit limits can return a partial tree; source failures fail the run. $0.004 per delivered discussion thread.

## Actor input object example

```json
{
  "feeds": [
    "top",
    "show"
  ],
  "storyIds": [],
  "storyUrls": [],
  "maxStories": 5,
  "maxFeedItems": 50,
  "maxCommentsPerStory": 500,
  "maxDepth": 20,
  "maxRequests": 800
}
```

# Actor output Schema

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

One validated discussion thread with public source data per row.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("jpmarketdata/hacker-news-story-comment-tree-export").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("jpmarketdata/hacker-news-story-comment-tree-export").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 '{}' |
apify call jpmarketdata/hacker-news-story-comment-tree-export --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jpmarketdata/hacker-news-story-comment-tree-export"
        }
    }
}
```

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/o7DroEjXrkaP6NGZk/builds/dTzPWdJfmIDmS3lxA/openapi.json
