# Lemmy Scraper - Posts, Comments, Communities & Monitor (`martin10291/lemmy-posts-comments-scraper`) Actor

Scrape Lemmy posts, comments, community stats and keyword search from lemmy.world, lemmy.ml and any other instance. No API key, no login, no proxy: official open Lemmy API, so it does not break. Only-new mode for keyword alerts. $0.25 per 1000 results.

- **URL**: https://apify.com/martin10291/lemmy-posts-comments-scraper.md
- **Developed by:** [Martin Petrov](https://apify.com/martin10291) (community)
- **Categories:** Social media, Lead generation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.18 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Lemmy Scraper - Posts, Comments, Communities & Monitor

Scrape **Lemmy posts, comments and community stats** from lemmy.world, lemmy.ml or any other Lemmy instance, using the official open **Lemmy HTTP API**. Search keywords across several instances and, with the only-new mode, get a **Lemmy keyword monitor** that returns each post once.

No login, no API key, no proxy. **$0.25 per 1000 results, no start fee.**

### What you get

- **Community posts** (New, Hot, Active, Top day / week / month / all time) with title, text, link, author, score, up/down votes, comment count, date and NSFW flag.
- **Keyword search** over posts, on one or many instances at once.
- **Single post URLs**, with their comments if you want them.
- **Comments** with author, score, date and nesting depth.
- **Community list** with subscribers, posts, comments, active users per month, NSFW flag and URL, useful to find where to post or monitor.
- **Only-new mode** with a monitor ID: schedule the actor and every run returns only items you have not received before.

### Input

| Field | Type | Description |
|---|---|---|
| `instances` | array | Lemmy domains to read. Default `["lemmy.world"]`. Searches and plain community names run on every instance listed. |
| `communities` | array | `technology`, `technology@lemmy.world` or `https://lemmy.world/c/technology`. |
| `searchQueries` | array | Keywords to search in posts. |
| `postUrls` | array | Single post URLs such as `https://lemmy.world/post/12345`. |
| `sort` | string | `New`, `Hot`, `Active`, `TopDay`, `TopWeek`, `TopMonth`, `TopAll`. Default `New`. |
| `includeComments` | boolean | Also save comments. Default `false`. |
| `maxCommentsPerPost` | integer | Comments per post. Default `20`. |
| `listCommunities` | boolean | Output community rows (the busiest communities of each instance, or the communities you entered). |
| `maxItems` | integer | Hard limit on rows saved in total, and the most you pay for. Default `50`. |
| `onlyNew` | boolean | Monitoring mode: only items not returned in earlier runs. |
| `monitorId` | string | Separate memory for each monitor. Default `default`. |

With the default input (community `technology` on lemmy.world) you get 50 posts in a few seconds.

#### Example: keyword monitor across instances

```json
{
  "instances": ["lemmy.world", "lemmy.ml", "sh.itjust.works"],
  "searchQueries": ["my product", "competitor name"],
  "sort": "New",
  "onlyNew": true,
  "monitorId": "brand-mentions",
  "maxItems": 200
}
```

Save it as a task and add a schedule (for example every hour). The first run returns the current matches, later runs only new ones.

#### Example: posts with comments

```json
{
  "communities": ["selfhosted@lemmy.world"],
  "sort": "TopWeek",
  "includeComments": true,
  "maxCommentsPerPost": 50,
  "maxItems": 500
}
```

#### Example: find communities

```json
{
  "instances": ["lemmy.world", "lemmy.ml"],
  "listCommunities": true,
  "maxItems": 100
}
```

### Output

Every row has a `type`: `post`, `comment` or `community`. A post:

```json
{
  "type": "post",
  "id": 54074897,
  "title": "FAA to finally ditch floppy disks in what it calls historic tech upgrade",
  "url": "https://lemmy.world/post/54074897",
  "linkUrl": "https://arstechnica.com/tech-policy/2026/11/faa-to-finally-ditch-floppy-disks/",
  "body": null,
  "community": "technology",
  "communityUrl": "https://lemmy.world/c/technology",
  "author": "return2ozma",
  "score": 12,
  "upvotes": 13,
  "downvotes": 1,
  "commentsCount": 3,
  "publishedAt": "2026-11-06T19:28:52Z",
  "nsfw": false,
  "instance": "lemmy.world",
  "scrapedAt": "2026-11-06T19:59:33Z"
}
```

A comment has `id`, `postId`, `postUrl`, `url`, `body`, `author`, `score`, `publishedAt`, `depth` (0 = top level) and `instance`. A community has `name`, `title`, `subscribers`, `postsCount`, `commentsTotal`, `activeUsersMonth`, `nsfw` and `url`. *Values above are illustrative.*

The `RUN_SUMMARY` record in the key-value store lists posts, comments and errors per source, plus `lastError`.

### Call it from code

```bash
curl -X POST "https://api.apify.com/v2/acts/martin10291~lemmy-posts-comments-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"communities": ["technology@lemmy.world"], "searchQueries": ["your brand"], "onlyNew": true, "monitorId": "my-brand", "maxItems": 50}'
```

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("martin10291/lemmy-posts-comments-scraper").call(run_input={"communities": ["technology@lemmy.world"], "searchQueries": ["your brand"], "onlyNew": True, "monitorId": "my-brand", "maxItems": 50})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

Schedule it hourly or daily in Apify Console (Schedules) with `onlyNew` to get only new items each time, or use it as a tool for AI agents through the Apify MCP server.

### Pricing

$0.25 per 1000 results (posts, comments or communities), no start fee. Use `maxItems` to cap the cost of a run.

### Good to know

- The actor uses the official Lemmy API v3 with a small number of parallel requests and waits when an instance answers with 429 or 5xx. Some instances limit or close their API; those sources are reported in the run summary and the others continue.
- Search and plain community names run on every instance in `instances`. The same federated post seen through two instances is saved once.
- Only-new mode remembers posts and comments by their federated ID, so a post found through two instances is not repeated. Community rows are snapshots of the current stats and are returned on every run.
- Comments are a flat list with a `depth` field, up to 8 levels deep.
- Authors are the public display names shown on Lemmy. No profile pages are scraped.
- Scores can differ slightly between instances because of federation delay.

### Legal

The actor reads public Lemmy content without logging in. Scraped content may include personal data such as usernames; process it in line with GDPR and other applicable laws and the terms of each instance. Do not use it for spam or harassment.

### FAQ

**How fresh is the data?** Live: every run reads the Lemmy API of each instance at run time.

**Which instances work?** Any public Lemmy instance with the v3 API (lemmy.world, lemmy.ml, sh.itjust.works, programming.dev ...). If one instance is down, the run continues with the others and the error is in `RUN_SUMMARY.lastError`.

**Does it need a login, key or proxy?** No. It uses the official open Lemmy API with a normal, honest client.

**What are the limits?** Lemmy pages hold up to 50 posts; very large `maxItems` values take longer. Private or deleted posts are not returned.

**Can AI agents use it?** Yes. Add it as a tool through the Apify MCP server (mcp.apify.com) and your AI agent can search Lemmy and watch keywords.

# Actor input Schema

## `instances` (type: `array`):

Lemmy servers to read, as domains (lemmy.world, lemmy.ml, sh.itjust.works, feddit.org). Search and plain community names run on every instance listed.

## `communities` (type: `array`):

Communities to scrape: a name (technology), name@instance (technology@lemmy.world) or a full community URL (https://lemmy.world/c/technology).

## `searchQueries` (type: `array`):

Keywords to search in posts on every listed instance (brand names, products, topics). Combine with Only new results for a keyword monitor.

## `postUrls` (type: `array`):

Single Lemmy post URLs (https://lemmy.world/post/12345). The post is saved, plus its comments when Include comments is on.

## `sort` (type: `string`):

Order of posts for communities and searches. Use New with Only new results for monitoring.

## `includeComments` (type: `boolean`):

Also save comments for every post. Each comment is one result row.

## `maxCommentsPerPost` (type: `integer`):

Upper limit of comments saved for each post.

## `listCommunities` (type: `boolean`):

Output community rows (name, title, subscribers, posts, comments, active users per month, NSFW, URL). Lists the most active communities of each instance, or the stats of the communities you entered.

## `maxItems` (type: `integer`):

Hard limit on rows saved in total (posts + comments + communities), and the most you pay for.

## `onlyNew` (type: `boolean`):

Monitoring mode: return only posts and comments not returned in earlier runs with the same Monitor ID.

## `monitorId` (type: `string`):

Name of the memory used by monitoring mode. Use a different ID for each set of searches.

## Actor input object example

```json
{
  "instances": [
    "lemmy.world"
  ],
  "communities": [
    "technology"
  ],
  "sort": "New",
  "includeComments": false,
  "maxCommentsPerPost": 20,
  "listCommunities": false,
  "maxItems": 50,
  "onlyNew": false,
  "monitorId": "default"
}
```

# Actor output Schema

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

One row per post, comment or community.

## `summary` (type: `string`):

Per-source counts, errors and the last error.

# 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 = {
    "instances": [
        "lemmy.world"
    ],
    "communities": [
        "technology"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("martin10291/lemmy-posts-comments-scraper").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 = {
    "instances": ["lemmy.world"],
    "communities": ["technology"],
}

# Run the Actor and wait for it to finish
run = client.actor("martin10291/lemmy-posts-comments-scraper").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 '{
  "instances": [
    "lemmy.world"
  ],
  "communities": [
    "technology"
  ]
}' |
apify call martin10291/lemmy-posts-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,martin10291/lemmy-posts-comments-scraper"
        }
    }
}
```

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/LePBztPrv4cYRkr0z/builds/EEfZZ5ORzVoD2Mefd/openapi.json
