# Mastodon Scraper (`donjuan_mime/mastodon-scraper`) Actor

Scrape Mastodon posts by hashtag, profile, trending, instance timeline, or link: text, boosts, favourites, replies, media, link cards, polls, and author stats. Works across the fediverse. No login needed.

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

## Pricing

$0.50 / 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.

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 Scraper: posts, replies, and author stats from hashtags, profiles, and timelines

Mastodon Scraper collects public posts from Mastodon and the wider fediverse. Scrape a hashtag, any account on any instance, the posts trending on an instance, an instance's local timeline, or a single post with its replies. For every post you get the text, content warning, language, publish and edit time, replies, boosts, and favourites, the images and videos with alt text, the link card, the poll, the hashtags and mentions, and the author's profile with follower and post counts.

You don't need a Mastodon account, an API key, or any code. Add hashtags, profiles, or links, press **Start**, and download the results as JSON, CSV, Excel, XML, or HTML. Or pull them into your app through the Apify API.

### What can you do with Mastodon data?

- **Monitor a topic or brand.** Follow a hashtag and see who posts about it and how people react.
- **Follow accounts.** Collect every post from journalists, researchers, open source projects, or public institutions, with boosts and favourites for each.
- **Analyze conversations.** Pull the replies to a post to study how a discussion unfolds.
- **See what an instance talks about.** Scrape trending posts or the local timeline of a community instance such as fosstodon.org.
- **Build datasets for research.** Clean text, language tags, content warnings, and timestamps make good input for topic, sentiment, or language analysis.

### What data does Mastodon Scraper extract?

| Group | Fields |
|---|---|
| Post | type (post, reply, or boost), ID, URL, ActivityPub URI, text, HTML, content warning, sensitive flag, language, created and edited time |
| Engagement | replies, boosts, favourites |
| Author | handle (user@instance), display name, profile URL, avatar, bio, followers, following, post count, bot flag, join date |
| Media | images, videos, GIFs, and audio with preview and alt text |
| Extras | link card, poll with votes per option, hashtags, mentions |
| Threads | the post a reply answers, and for collected replies the post they came from; for boosts, who boosted |

### How to scrape Mastodon

1. Open the actor and go to the **Input** tab.
2. Add hashtags, profiles, or Mastodon links, or turn on trending posts or the local timeline. You can mix them.
3. Set **Posts per source**, and turn on **Include replies** if you want the reply threads.
4. Press **Start**. When the run finishes, open the **Output** tab to preview the table, or press **Export** to download the data.

### Input

| Field | Type | Description |
|---|---|---|
| `hashtags` | array of strings | Hashtags, with or without `#`. |
| `profiles` | array of strings | `@user@instance`, `user@instance`, or a profile link. Each is read from its home instance, so you get its whole history. |
| `instance` | string | The server for hashtags, trending posts, and the local timeline. `mastodon.social` by default. |
| `includeTrending` | boolean | Also scrape the instance's trending posts. |
| `includeLocalTimeline` | boolean | Also scrape the latest posts by the instance's own users. |
| `startUrls` | array | Links to posts, profiles, hashtag pages, an instance's home page (local timeline), or its `/explore` page (trending), on any instance. |
| `maxItems` | integer | The maximum number of posts from each source. |
| `excludeReplies`, `excludeReblogs` | boolean | For profiles: leave out the account's replies or boosts. |
| `includeReplies` | boolean | Also collect the replies to every post that has them. |
| `maxRepliesPerPost` | integer | The maximum number of replies from each thread. |

Example input:

```json
{
  "hashtags": ["golang", "rust"],
  "profiles": ["@Gargron@mastodon.social"],
  "startUrls": [{ "url": "https://fosstodon.org/" }],
  "maxItems": 100,
  "includeReplies": true,
  "maxRepliesPerPost": 20
}
```

### Output

One dataset item per post, reply, or boost:

```json
{
  "type": "post",
  "id": "117640079247128922",
  "url": "https://mastodon.social/@Gargron/117640079247128922",
  "text": "#Dota2 has been my favourite game for 14 years.",
  "language": "en",
  "createdAtISO": "2026-11-18T23:39:14.529Z",
  "repliesCount": 2,
  "reblogsCount": 3,
  "favouritesCount": 30,
  "account": {
    "acct": "Gargron@mastodon.social",
    "displayName": "Eugen Rochko",
    "url": "https://mastodon.social/@Gargron",
    "followersCount": 381406
  },
  "hashtags": ["dota2"],
  "input": "@Gargron@mastodon.social"
}
```

### Tips and limits

- **Each instance sees its own slice of the fediverse.** A hashtag on mastodon.social shows the posts that reached mastodon.social. Run the same hashtag on several instances to widen coverage.
- **Some instances hide timelines from visitors.** mastodon.social, for example, shows its local timeline only to logged-in users. The run log says so, and the other sources still run.
- **Full-text search needs a login on Mastodon,** so the scraper works with hashtags instead.
- **Rate limits are handled.** Mastodon allows 300 requests per 5 minutes; the scraper waits when an instance asks it to.

### Is it legal to scrape Mastodon?

The scraper reads only public posts through Mastodon's public REST API, the same one Mastodon apps use. Personal data such as names and handles is protected by laws like the GDPR, and many fediverse users expect their posts not to be mass collected, so collect only what you need for a legitimate purpose and consult a lawyer if you are unsure.

# Actor input Schema

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

Hashtags to take posts from, with or without #. Read from the instance below, which sees posts from the whole fediverse that reached it.

## `profiles` (type: `array`):

Accounts to take posts from: @user@instance, user@instance, or a profile link such as https://mastodon.social/@Gargron. Each is read from its home instance.

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

The Mastodon server for hashtags, trending posts, and the local timeline, and for profiles given without a domain.

## `includeTrending` (type: `boolean`):

Also scrape the posts trending on the instance right now.

## `includeLocalTimeline` (type: `boolean`):

Also scrape the latest posts by the instance's own users. Some large instances, mastodon.social among them, show this only to logged-in users.

## `startUrls` (type: `array`):

Links on any Mastodon instance: a post (https://instance/@user/123), a profile (https://instance/@user), a hashtag (https://instance/tags/golang), the instance itself for its local timeline, or /explore for its trending posts.

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

The maximum number of posts from each hashtag, profile, timeline, or start URL. Replies from "Include replies" come on top of this.

## `excludeReplies` (type: `boolean`):

For profiles: leave out posts that answer someone else.

## `excludeReblogs` (type: `boolean`):

For profiles: leave out posts the account boosted from others.

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

Also collect the replies to every post that has them, one item per reply.

## `maxRepliesPerPost` (type: `integer`):

The maximum number of replies from each post's thread. Leave empty for all the instance knows.

## Actor input object example

```json
{
  "hashtags": [
    "golang"
  ],
  "instance": "mastodon.social",
  "includeTrending": false,
  "includeLocalTimeline": false,
  "maxItems": 50,
  "excludeReplies": false,
  "excludeReblogs": false,
  "includeReplies": false
}
```

# Actor output Schema

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

One item per Mastodon post, reply, or boost.

# 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 = {
    "hashtags": [
        "golang"
    ],
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("donjuan_mime/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 = {
    "hashtags": ["golang"],
    "maxItems": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("donjuan_mime/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 '{
  "hashtags": [
    "golang"
  ],
  "maxItems": 50
}' |
apify call donjuan_mime/mastodon-scraper --silent --output-dataset

```

## MCP server setup

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