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

Mastodon posts by hashtag, account profiles with recent posts, and account / hashtag search on any instance (mastodon.social, fosstodon.org …). Public JSON API, no login, no browser.

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

## Pricing

$2.00 / 1,000 item scrapeds

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

**Mastodon scraper for hashtag timelines, account profiles and search on any instance, with no login and no API key.** Pull the latest Mastodon posts for any hashtag, an account's profile plus its recent posts, or search accounts and hashtags on `mastodon.social`, `fosstodon.org`, `mstdn.jp`, `hachyderm.io` and others. It uses the instance's public JSON API, so runs are fast and you pay per result.

### What you can do with it

- **Brand / topic monitoring** — schedule `hashtag` mode for your product or industry tags, feed new posts into Slack, a sheet, or an LLM summarizer.
- **Creator & competitor tracking** — `account` mode gives follower / post counts plus the latest posts with boosts, favourites and replies per post.
- **Audience research** — `search` mode with `searchType: accounts` finds accounts by keyword with follower stats and profile links; `searchType: hashtags` returns 7-day usage history for trend scouting.
- **Dataset building** — hashtag timelines are federated, so one instance gives you posts from across the Fediverse. Pick `local: true` to restrict to one community.
- **Automated feeds** — Schedule it on Apify and pipe results to Google Sheets, Slack, n8n or Make via the Apify integration.
- **Hashtag trend tracking** — run `searchType: hashtags` daily and chart `uses_7d` / `accounts_7d` to see which topics are rising.

### Output example

Mode `hashtag` / posts in mode `account` (`type: "status"`):

```json
{
  "instance": "mastodon.social",
  "type": "status",
  "id": "117541462375141480",
  "url": "https://indieweb.social/@jbz/117541462295503480",
  "created_at": "2026-11-01T13:39:39.000Z",
  "text": "👉 Electrocutions, 'mental terror' and withheld wages: the human cost of the AI data-center boom …",
  "content_html": "<p>👉 Electrocutions, …</p>",
  "language": "en",
  "visibility": "public",
  "sensitive": false,
  "spoiler_text": null,
  "replies_count": 0,
  "reblogs_count": 4,
  "favourites_count": 7,
  "is_reblog": false,
  "reblogged_by": null,
  "in_reply_to_id": null,
  "account": "jbz@indieweb.social",
  "account_display_name": "JBZ",
  "account_url": "https://indieweb.social/@jbz",
  "account_followers": 1240,
  "account_bot": false,
  "tags": ["datacenters", "ai"],
  "mentions": [],
  "media": [{ "type": "image", "url": "https://files.mastodon.social/…/original/….jpg", "description": "Alt text" }],
  "card_url": "https://www.theguardian.com/…",
  "card_title": "Electrocutions, 'mental terror' and withheld wages…",
  "poll": null
}
```

Mode `account` first row / mode `search` with `accounts` (`type: "account"`):

```json
{
  "instance": "mastodon.social",
  "type": "account",
  "id": "1",
  "acct": "Gargron",
  "username": "Gargron",
  "display_name": "Eugen Rochko",
  "url": "https://mastodon.social/@Gargron",
  "note": "Executive Strategy & Product Advisor of Mastodon …",
  "avatar": "https://files.mastodon.social/accounts/avatars/…",
  "header": "https://files.mastodon.social/accounts/headers/…",
  "followers_count": 381769,
  "following_count": 767,
  "statuses_count": 82707,
  "created_at": "2016-03-16T00:00:00.000Z",
  "last_status_at": "2026-11-01",
  "bot": false,
  "locked": false,
  "discoverable": true,
  "fields": [{ "name": "Website", "value": "zeonfederated.com", "verified_at": "2024-01-02T10:00:00.000Z" }]
}
```

Mode `search` with `hashtags` (`type: "hashtag"`):

```json
{ "instance": "mastodon.social", "type": "hashtag", "name": "AI", "url": "https://mastodon.social/tags/ai", "uses_7d": 10263, "accounts_7d": 4177, "uses_today": 601, "following": null }
```

### Input

| Field | Description |
|---|---|
| `instance` | Server domain. Default `mastodon.social`. |
| `mode` | `hashtag` (default), `account`, `search` |
| `hashtags` | Mode `hashtag`. Tag names without `#`. Newest first, paginated as far as `maxItems` needs. |
| `accounts` | Mode `account`. `user`, `@user`, `user@other.instance`, or profile URL. Remote accounts must already be known to the chosen instance. |
| `local` | Mode `hashtag`. Only posts that originate on `instance`. |
| `excludeReplies` / `excludeReblogs` | Mode `account`. Default: replies hidden, boosts kept (`is_reblog: true`, original author in `account`). |
| `query`, `searchType` | Mode `search`. `accounts` (default) or `hashtags`. Anonymous search returns at most 40 results; full-text post search needs a logged-in user on Mastodon, so it is not offered. |
| `maxItems` | Stop after N rows total. Default 100. |

### Pricing

Pay per item: one event per dataset row (post, account, or hashtag). Nothing is charged for rows that are never produced.

### Notes

- Hashtag timelines are public and federated. Posts set to unlisted/followers-only never appear.
- Instances rate-limit anonymous clients to 300 requests per 5 minutes; at 40 posts per request that is ~12,000 rows per 5 minutes per instance.
- Unknown account → warning in the log, no row.

### FAQ

#### Do I need an API key or account?

No. It only uses public, anonymous endpoints. Instances rate-limit anonymous clients to 300 requests per 5 minutes (about 12,000 posts per 5 minutes per instance).

#### How much does it cost?

$0.002 per result and nothing else: with pay-per-event pricing you are not billed for Apify compute. 100 results cost $0.20, and the Apify free plan's $5 monthly credit covers about 2,500 results. Rows that are never produced are never charged.

#### How do I get the data into Google Sheets or my app?

Export the run's dataset as CSV, JSON or Excel from the Apify Console, read it from the dataset API endpoint, or connect it to Google Sheets, Slack, n8n, Make or Zapier with Apify integrations.

#### Is it legal to scrape Mastodon?

It only reads public data via the platform's public API and respects rate limits. You are responsible for complying with Mastodon's terms and applicable law.

#### Can I search the full text of Mastodon posts?

No. Mastodon only allows full-text post search for logged-in users, so this actor does not offer it. Use hashtag mode for topic tracking, or search accounts and hashtags (anonymous search returns at most 40 results).

### Related Actors

- [Lemmy Scraper](https://apify.com/gogumaa/lemmy-scraper)
- [Hacker News Scraper](https://apify.com/gogumaa/hacker-news-scraper)
- [Kick Streams Scraper](https://apify.com/gogumaa/kick-streams-scraper)

# Actor input Schema

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

Mastodon server domain, e.g. mastodon.social, fosstodon.org, mstdn.jp. Any instance with the public API enabled.

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

hashtag = latest public posts for each hashtag. account = profile + recent posts per account. search = find accounts or hashtags by keyword.

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

Mode=hashtag. Without #. Posts are newest first.

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

Mode=account. @user, user@other.instance, or profile URL. The first row per account is the profile, then its posts.

## `query` (type: `string`):

Mode=search.

## `searchType` (type: `string`):

Mode=search. Full-text post search requires login on Mastodon, so only accounts and hashtags are available.

## `local` (type: `boolean`):

Mode=hashtag. Only posts originating on this instance.

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

Mode=account.

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

Mode=account. Boosted posts are returned with is_reblog=true and the original author in account.

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

Stop after this many rows (total across all hashtags / accounts).

## Actor input object example

```json
{
  "instance": "mastodon.social",
  "mode": "hashtag",
  "hashtags": [
    "ai",
    "opensource"
  ],
  "accounts": [
    "Gargron"
  ],
  "query": "",
  "searchType": "accounts",
  "local": false,
  "excludeReplies": true,
  "excludeReblogs": false,
  "maxItems": 100
}
```

# Actor output Schema

## `items` (type: `string`):

One record per post / account / hashtag: text, url, created_at, engagement counts, author, tags, media; or profile stats; or hashtag 7-day usage.

# 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": [
        "ai",
        "opensource"
    ],
    "accounts": [
        "Gargron"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gogumaa/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": [
        "ai",
        "opensource",
    ],
    "accounts": ["Gargron"],
}

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

```

## MCP server setup

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