# Discourse Forum Reader (`adage/discourse-forum-reader`) Actor

- **URL**: https://apify.com/adage/discourse-forum-reader.md
- **Developed by:** [Adage](https://apify.com/adage) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 post reads

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

## Discourse Forum Reader

### Introduction

Discourse Forum Reader reads the posts of any public Discourse forum and writes one dataset record for every post. You give it the base address of a forum and a limit. It reads the forum's public JSON pages, walks the list of latest topics, opens each topic, and writes the posts in a fixed set of ten fields. Text comes out as plain text: character references such as \&lt; are decoded first and then every tag is removed, so markup quoted inside a post is removed as well. It accepts a forum by its public host name only, and it caps the size of each post and each forum answer and the number of pages and requests in a run, as the limits below say.

It reads public topics only. It never logs in, never uses cookies, never uses a proxy and never opens a browser. It fetches from the forum you name and from no other host.

### Tutorial

1. Open the Actor's Input tab.
2. In Forum URL, enter the base address of a public Discourse forum. Only the scheme and host are used, so a path after the host is ignored. Give the forum's public host name: an IP address, `localhost`, a name ending in .local, .internal or .localhost, a name with no dot, a name with an empty part (two dots in a row), and a port other than 80 or 443 are refused with BAD_INPUT before anything is fetched.
3. In Maximum posts, enter how many post records you want. The default is 100, the smallest value is 1 and the largest is 100000.
4. Start the run. Posts are written to the dataset as they are read, the most recently active topics first, and each topic's posts in thread order.
5. When the run ends, open the Output tab, or export the dataset in any format the platform offers. To fetch results from code, see the dataset API on docs.apify.com.

Limits to know before you start:

- Public topics only. A forum that has login_required switched on, or one that answers a read with 403, fails the run with a named error (LOGIN_REQUIRED or FORBIDDEN) and nothing is charged.
- At most one request a second is sent to the forum, well inside the pace Discourse allows. When the forum answers 429 the Actor waits for the time in its Retry-After header, up to 120 seconds, then tries again, up to three times. When the header is missing it waits 10 seconds. If the fourth attempt of a request is answered 429, the Actor makes one final attempt after the time asked or 75 seconds, whichever is longer, to ride out a per-minute limit. A 429 on that final attempt fails the run with RATE_LIMITED. When the forum asks for more than 120 seconds, or when the waits for 429 answers in one run would add up to more than 240 seconds, the run fails at once with RATE_LIMITED. The request that failed is not charged, and the posts written before it stay in the dataset.
- A topic deleted between the topic list and the read is skipped and logged.
- The host check reads the forum address as you typed it. A host name that resolves to a private or internal address is not detected, because the Actor makes no address lookup of its own.
- A post whose HTML body is larger than 262144 bytes is skipped and logged. It is not written and not charged, and it does not count toward Maximum posts. A forum answer larger than 8 MB fails the run with SHAPE.
- A post listed twice in one topic is written once, even when the forum writes its id in two forms such as 1 and 01. A topic id, or the id of a post that would be written, that is not a positive whole number fails the run with SHAPE before it is used in an address or a record.
- The run stops at Maximum posts, at the end of the forum's topic list (an empty page, or a page with no topic not seen before), after 2000 topic-list pages (page-cap), after 10 requests for each post you asked for plus 200 (request-cap), or when the pay-per-event charge limit you set for the run is reached.
- A run therefore sends at most 10 times Maximum posts plus 200 requests to the forum, retries included: 1,200 requests for the default of 100 posts.

### Pricing

This Actor uses pay-per-event pricing. One event named post is charged for each post record written to the dataset. Nothing is charged for a request, for a topic that is skipped, for a deleted or hidden post that is not written, or for a run that fails before it writes a record. The price of the event is set in the Apify Console by the Actor's owner and shown on the Actor's page. You can cap what a run may spend with the maximum charge setting of the run, and the Actor stops cleanly when that cap is reached.

### Input and output examples

Input, the forum the Input tab fills in first:

```json
{
  "forumUrl": "https://discuss.python.org",
  "maxPosts": 100
}
```

Input, a second forum, Discourse's own:

```json
{
  "forumUrl": "https://meta.discourse.org",
  "maxPosts": 1000
}
```

Each dataset record has these ten fields:

- forumUrl: the forum's base address.
- topicId: the numeric id of the topic.
- topicTitle: the topic's title.
- postId: the numeric id of the post.
- postNumber: the post's position in its topic, starting at 1.
- authorUsername: the author's username.
- createdAt: when the post was created, as an ISO 8601 timestamp.
- text: the post body as plain text, with the HTML tags removed.
- likeCount: the number of likes on the post, 0 when there are none.
- postUrl: the address of the post.

One record:

```json
{
  "forumUrl": "https://meta.discourse.org",
  "topicId": 1539,
  "topicTitle": "Why offer Private Messaging?",
  "postId": 2466,
  "postNumber": 1,
  "authorUsername": "singpolyma",
  "createdAt": "2013-02-06T18:08:04.450Z",
  "text": "Why? Isn’t this a misfeature that’s come in from existing webforum software?",
  "likeCount": 0,
  "postUrl": "https://meta.discourse.org/t/why-offer-private-messaging/1539/1"
}
```

### FAQ and support

#### Can it read a private forum?

No. It reads what an anonymous visitor can read. If the forum requires a login, the run fails with LOGIN_REQUIRED, or with FORBIDDEN when the forum answers 403, and no post is charged.

#### What happens to deleted posts?

Posts deleted by their author or a moderator, hidden posts and system messages such as small-action notices are skipped. They are not written and not charged.

#### How fast does it read?

No faster than one request a second to the forum. Reading a topic takes one request, plus one more for each further twenty posts. A large forum therefore takes time, so set Maximum posts to what you need. When a forum answers 429, the run also waits for the time it asks, up to 120 seconds, and at least 75 seconds before its final attempt; the 429 waits of one run add up to 240 seconds at most.

#### Why did my run stop?

The run log ends with a summary line that names the reason. The limit reason means Maximum posts was reached. The end reason means the forum's topic list ran out. The page-cap reason means 2000 pages of the topic list were read, and the request-cap reason means the run used its allowance of requests (10 for each post asked for, plus 200); the posts written before either stay in the dataset and nothing more is charged. The charge-limit reason means the maximum charge you set for the run was reached. Any other ending is an error named at the start of its message, such as TIMEOUT, RATE_LIMITED, SHAPE or UNREACHABLE, and the posts written before it stay in the dataset.

#### Where do I report a problem?

Use the Issues tab on this Actor's page on the platform. Include the forum address, the input and the run's log.

# Actor input Schema

## `forumUrl` (type: `string`):

Base URL of a public Discourse forum.

## `maxPosts` (type: `integer`):

Stop after this many post records.

## Actor input object example

```json
{
  "forumUrl": "https://discuss.python.org",
  "maxPosts": 100
}
```

# Actor output Schema

## `posts` (type: `string`):

The post records as JSON items of the run's default dataset.

# 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 = {
    "forumUrl": "https://discuss.python.org"
};

// Run the Actor and wait for it to finish
const run = await client.actor("adage/discourse-forum-reader").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 = { "forumUrl": "https://discuss.python.org" }

# Run the Actor and wait for it to finish
run = client.actor("adage/discourse-forum-reader").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 '{
  "forumUrl": "https://discuss.python.org"
}' |
apify call adage/discourse-forum-reader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,adage/discourse-forum-reader"
        }
    }
}
```

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/TBtv2ZWaG1NaTFHm0/builds/hfr4E1lzQxt63xHZB/openapi.json
