# Mastodon Posts Scraper: Hashtags, Accounts, Trending, Threads (`tidyharvest/mastodon-scraper`) Actor

Scrape public Mastodon posts by hashtag, account, trending, local timeline or thread: text, author, engagement counts, tags, media and link previews. No login or proxy. $0.80 per 1,000 posts.

- **URL**: https://apify.com/tidyharvest/mastodon-scraper.md
- **Developed by:** [TidyHarvest](https://apify.com/tidyharvest) (community)
- **Categories:** Social media
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.48 / 1,000 post scrapeds

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

## Mastodon Posts Scraper: Hashtags, Accounts, Trending, Threads

Pull **Mastodon posts** from any public instance in clean JSON: **full text and HTML, author, follower count, replies, boosts and favourites, hashtags, mentions, media with alt text, link previews and polls**. Search **hashtags**, read **accounts** (`@user@instance`), grab **trending posts**, an instance's **local timeline**, or a **whole conversation thread**.

**$0.80 per 1,000 posts.** No login, API key, browser or proxy: it reads the documented public Mastodon API that every instance offers, so runs are fast (50 posts in a couple of seconds) and cheap.

### What you can do with it

- **Social listening and brand monitoring:** track a hashtag or keyword across the fediverse with a daily scheduled run and *Only posts newer than: 24 hours*.
- **Research and datasets:** collect posts by topic, language or community (fosstodon.org, hachyderm.io, scholar.social...) for NLP, sentiment or discourse studies.
- **Content and news curation:** pull trending posts or link previews (`card`) to feed a newsletter, Slack channel or dashboard.
- **Account archiving and analytics:** export an account's public posts with engagement counts.
- **Conversation analysis:** fetch the full reply tree of a viral post.

### Input

| Field | What it does |
|---|---|
| `mode` | `hashtag` (default), `accounts`, `trending`, `public-local` or `thread`. |
| `hashtags` | `technology`, `#ai`, `linux@fosstodon.org` or `https://fosstodon.org/tags/linux`. |
| `accounts` | `@user@instance`, `user@instance` or a profile URL like `https://hachyderm.io/@user`. |
| `postUrls` | For thread mode: post links. Returns parents, the post and its public replies. |
| `instance` | Server for hashtags, trending and local timeline (default `mastodon.social`). |
| `onlyNewerThan` | `2026-10-01`, `24 hours`, `7 days`... Older posts are skipped. |
| `includeReplies`, `includeBoosts` | Off by default. |
| `onlyMedia` | Keep only posts with images, video or audio. |
| `includeProfile` | Accounts mode: one free `type: profile` row per account (bio, avatar, header, profile fields, counts). Default on. |
| `languages` | ISO codes, e.g. `en`, `de`. |
| `keywords` | Keep posts whose text, content warning or hashtags contain any of these. |
| `maxItemsPerSource`, `maxItems` | Caps to control cost (`maxItems` defaults to 50; up to 10,000). |

### How to use

1. Pick a **mode** and enter hashtags, accounts or post URLs (or just press Start for the latest `#technology` posts).
2. Optionally add a date window, languages or keywords, and set **Max posts in total**.
3. Run, then download as JSON, CSV or Excel, or connect it to Sheets, Slack or a webhook with Apify integrations.

Example:

```json
{ "mode": "hashtag", "hashtags": ["opensource", "linux@fosstodon.org"], "languages": ["en"], "onlyNewerThan": "3 days", "maxItems": 500 }
```

### Output

One item per post:

```json
{
  "id": "117426638870219047",
  "url": "https://social.example/@techwire/117426638762940508",
  "uri": "https://social.example/users/techwire/statuses/117426638762940508",
  "createdAt": "2026-10-12T06:58:20.000Z", "editedAt": null,
  "text": "Google Docs and Drive now support markdown files natively ...",
  "content": "<p>Google Docs and Drive now support markdown files natively</p>...",
  "language": "en", "sensitive": false, "spoilerText": null,
  "isReply": false, "inReplyToId": null, "isBoost": false, "boostedBy": null,
  "account": { "acct": "techwire@social.example", "displayName": "TechWire", "url": "https://social.example/@techwire",
               "followers": 1520, "following": 3, "statusesCount": 48210, "bot": true, "createdAt": "2025-04-01T00:00:00.000Z" },
  "repliesCount": 0, "reblogsCount": 2, "favouritesCount": 5, "quotesCount": 0,
  "tags": ["tech", "technology", "ai"], "mentions": [],
  "media": [{ "type": "image", "url": "https://...", "previewUrl": "https://...", "description": "alt text" }],
  "card": { "url": "https://9to5google.com/...", "title": "...", "description": "...", "image": "https://...", "providerName": "9to5Google" },
  "poll": null,
  "instance": "mastodon.social", "source": "#technology@mastodon.social", "scrapedAt": "2026-10-12T07:00:00+00:00"
}
```

`id` is the post's id on the instance it was read from; `url`/`uri` point to the original post. Counts are as seen by that instance, so for posts from other servers they can lag behind the original.

### Pricing

Pay per post returned: **$0.80 per 1,000 posts** (`post-scraped`). Language, keyword, date and reply/boost filters run before billing, and duplicates across sources are removed, so you only pay for posts you keep. A run that finds nothing fails instead of silently returning an empty dataset.

### Privacy-respecting by design

- Only **public** posts are returned (no unlisted, followers-only or direct posts).
- Posts from accounts that opted out of search-engine indexing (`noindex`) are **skipped**, and such accounts are refused in Accounts mode. The run summary (`SUMMARY` in the key-value store) reports how many were skipped.
- Requests are spaced out and each instance's rate-limit headers (`X-RateLimit-*`) are honoured.

### Limits and notes

- Post rows have `type: "post"`; account profile rows (`type: "profile"`) are free.
- Each instance only knows the posts that reached it. A hashtag on `mastodon.social` covers a lot of the fediverse but not all of it; add `tag@otherinstance` to widen coverage.
- Full-text search of posts is not offered: Mastodon requires a logged-in user for that. Use hashtags plus `keywords` instead.
- Some instances (including mastodon.social) require login for their local public timeline or trends. Those sources are reported as failed, never bypassed.
- Unauthenticated API access is limited to about 300 requests per 5 minutes per instance (40 posts per request). Very large pulls slow down or stop politely when that limit is near.
- Thread mode returns what the post's instance exposes publicly (large threads may be truncated by the server).
- Post content belongs to its authors. Use the data in line with their rights, each instance's rules and the privacy laws that apply to you.

Not affiliated with, endorsed by or sponsored by Mastodon gGmbH or any Mastodon instance.

# Actor input Schema

## `mode` (type: `string`):

Hashtag timelines (uses Hashtags), posts from accounts (uses Accounts), trending posts or the local public timeline of the chosen Instance, or the full conversation around posts (uses Post URLs).

## `hashtags` (type: `array`):

Used in Hashtag mode. One per line: `technology`, `#ai`, `opensource@fosstodon.org` (read that tag on another instance) or a tag URL like `https://fosstodon.org/tags/linux`. Each instance shows the posts it knows about, including ones federated from other servers.

## `accounts` (type: `array`):

Used in Accounts mode. `@user@instance`, `user@instance`, a profile URL like `https://fosstodon.org/@user`, or a bare `user` on the chosen Instance. Posts are read from the account's home instance.

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

Used in Thread mode. Post links like `https://mastodon.social/@user/1234567890`. Returns the post, its parents and its public replies.

## `instance` (type: `string`):

Mastodon server to read from, e.g. `mastodon.social`, `fosstodon.org`, `hachyderm.io`. Used for hashtags and bare usernames without their own instance, and for Trending and Local public modes. Some instances (including mastodon.social) require login for their local timeline; that is reported, not bypassed.

## `onlyNewerThan` (type: `string`):

A date (`2026-10-01`, ISO date-time) or a relative age (`24 hours`, `7 days`, `2 weeks`). Older posts are skipped and paging stops. Great for scheduled runs.

## `includeReplies` (type: `boolean`):

Also return posts that are replies to other posts. Thread mode always includes replies.

## `includeBoosts` (type: `boolean`):

Also return posts an account boosted (reblogged). The original post is returned with `isBoost: true` and `boostedBy`.

## `onlyMedia` (type: `boolean`):

Keep only posts with images, video or audio attached.

## `includeProfile` (type: `boolean`):

Accounts mode: add one free `type: profile` row per account with bio, avatar, header image, profile fields and follower counts.

## `languages` (type: `array`):

Keep only posts tagged with one of these ISO 639-1 codes, e.g. `en`, `de`, `ja`. Empty = all languages.

## `keywords` (type: `array`):

Keep a post only if its text, content warning or hashtags contain one of these. Empty = all.

## `maxItemsPerSource` (type: `integer`):

Cap per hashtag, account, thread or instance. Empty = only the total cap applies.

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

Hard cap on posts for the whole run (also caps your cost). Raise it for bigger pulls; up to 10,000.

## Actor input object example

```json
{
  "mode": "hashtag",
  "hashtags": [
    "technology"
  ],
  "accounts": [
    "@Gargron@mastodon.social"
  ],
  "instance": "mastodon.social",
  "includeReplies": false,
  "includeBoosts": false,
  "onlyMedia": false,
  "includeProfile": true,
  "maxItems": 50
}
```

# Actor output Schema

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

Mastodon posts, one item per post, with author, counts, tags, media and link preview.

# 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 = {
    "accounts": [
        "@Gargron@mastodon.social"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidyharvest/mastodon-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 = { "accounts": ["@Gargron@mastodon.social"] }

# Run the Actor and wait for it to finish
run = client.actor("tidyharvest/mastodon-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 '{
  "accounts": [
    "@Gargron@mastodon.social"
  ]
}' |
apify call tidyharvest/mastodon-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tidyharvest/mastodon-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/C5Ggc0k3ZVZ9ZXRtY/builds/HJQDxt9DcxBKscAH5/openapi.json
