# Mastodon Scraper - Hashtags, Accounts, Trends & Profiles (`hichemdev/mastodon-scraper`) Actor

Scrape Mastodon and the Fediverse: posts by hashtag, posts from any account on its home server, trending posts and hashtags, and account profiles. Clean text, engagement counts, hashtags, mentions, media. Any instance, no login or API key.

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

## Pricing

from $2.00 / 1,000 posts

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 - Hashtags, Accounts, Trends & Profiles

Collect public posts and profiles from **Mastodon and the wider Fediverse** through the official Mastodon REST API. No login, no API key, no browser, no proxy needed.

Five things it can do:

| Mode | What you get |
|---|---|
| **Posts by hashtag** | Every public post a server has seen for one or more hashtags, newest first |
| **Posts from accounts** | An account's posts, read straight from its **home server** (accurate counts, full history) |
| **Account profiles** | Bio, follower / following / post counts, verified links, avatar, join date, last activity |
| **Trending posts** | The posts a server is currently ranking as trending |
| **Trending hashtags** | Trending tags with uses and unique people per day for the last 7 days |

Works on any Mastodon-compatible server: `mastodon.social` by default, plus any list you pass (`fosstodon.org`, `hachyderm.io`, `infosec.exchange`, ...).

### Who it is for

- **Brand and product monitoring** - schedule a daily hashtag run (`#yourbrand`, `#yourproduct`) with *Posts newer than* set, and get only new mentions.
- **Social listening and research** - collect Fediverse discussion on a topic (`#ai`, `#climate`, `#elections`) with clean text, language codes and engagement counts for analysis or LLM pipelines.
- **Influencer and community discovery** - pull profiles to compare follower counts, posting activity and verified links.
- **Trend tracking** - snapshot trending posts and hashtags on several servers every hour to see what the tech, science or journalism communities are talking about.
- **Archiving** - export the posts of public accounts you follow for backup or analysis.

### Input example

```json
{
  "mode": "hashtag",
  "hashtags": ["ai", "opensource"],
  "instances": ["mastodon.social", "fosstodon.org"],
  "maxItems": 200,
  "sinceDate": "2026-11-01"
}
```

Accounts (account and profile modes) can be given in any common form - each is read from its own home server:

```json
{
  "mode": "account",
  "accounts": ["@Gargron@mastodon.social", "kev@fosstodon.org", "https://hachyderm.io/@nova"],
  "excludeReplies": true,
  "maxItems": 100
}
```

#### Input fields

| Field | Description |
|---|---|
| `mode` | `hashtag`, `account`, `profile`, `trending` or `trendingTags`. Default `hashtag`. |
| `hashtags` | Hashtags, with or without `#`. Each is scraped on every instance. |
| `accounts` | `@user@server`, `user@server`, or a profile URL. A bare `user` is looked up on the first instance. |
| `instances` | Servers to query for hashtag and trending modes. Default `mastodon.social`. |
| `maxItems` | Max results per hashtag-instance pair, per account, or per instance (trending). Default 200. |
| `sinceDate` | `YYYY-MM-DD` or ISO time. Hashtag and account modes stop paging once posts are older. |
| `excludeReplies` / `excludeReblogs` | Account mode: skip replies / boosts. |
| `onlyMedia` | Only posts with images, video or audio. |
| `localOnly` | Hashtag mode: only posts written by the queried server's own users. |
| `proxyConfiguration` | Optional, not needed. |

With an empty input the actor scrapes the latest 200 `#ai` posts on mastodon.social.

### Output example

A real post from a verified run (hashtag `ai` on mastodon.social):

```json
{
  "recordType": "post",
  "id": "117570933266066389",
  "url": "https://omgwars.com/@chris/117570933106369093",
  "uri": "https://omgwars.com/users/chris/statuses/117570933106369093",
  "createdAt": "2026-11-06T18:34:28.000Z",
  "editedAt": null,
  "content": "\"Technology is NOT a neutral tool. This assessment assumes we can separate technology from the context it's deployed into, but we should not: ...\"\n\nhttps://stay-human.sofialiguori.com/\n\n#AI #Google #DeepMind",
  "language": "en",
  "visibility": "public",
  "sensitive": false,
  "spoilerText": null,
  "authorUsername": "chris",
  "authorAcct": "chris@omgwars.com",
  "authorDisplayName": "Chris J. Karr",
  "authorUrl": "https://omgwars.com/@chris",
  "authorFollowersCount": 322,
  "authorFollowingCount": 1049,
  "authorStatusesCount": 3203,
  "authorIsBot": false,
  "repliesCount": 0,
  "reblogsCount": 0,
  "favouritesCount": 0,
  "hashtags": ["ai", "google", "deepmind"],
  "mentions": [],
  "mediaUrls": [],
  "mediaTypes": [],
  "linkUrl": "https://stay-human.sofialiguori.com/",
  "linkTitle": "Stay Human.",
  "isReply": false,
  "inReplyToId": null,
  "isReblog": false,
  "rebloggedBy": null,
  "rebloggedAt": null,
  "instance": "mastodon.social",
  "source": "#ai",
  "scrapedAt": "2026-11-06T18:38:32.771Z"
}
```

A profile:

```json
{
  "recordType": "profile",
  "id": "1",
  "username": "Gargron",
  "acct": "Gargron@mastodon.social",
  "displayName": "Eugen Rochko",
  "url": "https://mastodon.social/@Gargron",
  "bio": "Executive Strategy & Product Advisor of @Mastodon. Film photography, prog metal, Dota 2. Likes all things analog. Luddite.",
  "createdAt": "2016-03-16T00:00:00.000Z",
  "lastStatusAt": "2026-11-06",
  "followersCount": 381197,
  "followingCount": 769,
  "statusesCount": 82762,
  "locked": false,
  "bot": false,
  "group": false,
  "discoverable": true,
  "avatarUrl": "https://files.mastodon.social/accounts/avatars/000/000/001/original/6b2384b33799a0dd.png",
  "headerUrl": "https://files.mastodon.social/accounts/headers/000/000/001/original/d13e4417706a5fec.jpg",
  "profileFields": [
    { "name": "GitHub", "value": "https://github.com/Gargron", "verified": true },
    { "name": "Portfolio", "value": "https://eugenrochko.com", "verified": true }
  ],
  "instance": "mastodon.social",
  "source": "@Gargron@mastodon.social"
}
```

A trending hashtag:

```json
{
  "recordType": "hashtag",
  "rank": 1,
  "name": "WindowFriday",
  "url": "https://mastodon.social/tags/windowfriday",
  "usesToday": 117,
  "accountsToday": 93,
  "uses7d": 125,
  "accounts7d": 100,
  "history": [{ "date": "2026-11-06", "uses": 117, "accounts": 93 }, { "date": "2026-11-05", "uses": 3, "accounts": 2 }],
  "instance": "mastodon.social"
}
```

#### Post fields

| Field | Meaning |
|---|---|
| `id`, `url`, `uri` | Post id on the queried server, link to the post on its origin server, ActivityPub id |
| `createdAt`, `editedAt` | ISO timestamps |
| `content` | Plain text: HTML removed, paragraphs and line breaks kept as newlines, entities decoded |
| `language` | ISO 639-1 code set by the author's app (can be null) |
| `visibility`, `sensitive`, `spoilerText` | Visibility, content-warning flag and content-warning text |
| `author*` | Username, full `user@server` handle, display name, profile URL, followers, following, post count, bot flag |
| `repliesCount`, `reblogsCount`, `favouritesCount` | Engagement counts (see caveats) |
| `hashtags`, `mentions` | Tag names and fully qualified mentioned handles |
| `mediaUrls`, `mediaTypes` | Original media file URLs and their types (image, video, gifv, audio) |
| `linkUrl`, `linkTitle` | Link-preview card, when the post shares a link |
| `isReply`, `inReplyToId` | Reply information |
| `isReblog`, `rebloggedBy`, `rebloggedAt` | For boosts: the **original** post's content and author are returned, plus who boosted it and when |
| `instance`, `source` | Server that was queried, and the hashtag / account / `trending` that produced the row |

### Caveats - stated plainly

- **Each server only sees part of the Fediverse.** A hashtag timeline on mastodon.social contains posts that reached mastodon.social. Add more servers in `instances` for wider coverage; duplicates are removed automatically.
- **Engagement counts are as seen by the queried server.** For a post from another server, mastodon.social may report fewer likes and boosts than the origin server. Account mode reads from the home server, so its counts are the authoritative ones.
- **No keyword (full-text) search.** Mastodon's search API returns no posts to anonymous callers, and full-text search only covers posts users opted in to. Use hashtags instead - they are how Mastodon users label topics.
- **Some servers restrict anonymous API access** or are not Mastodon (e.g. Misskey). If an account's home server refuses, the actor falls back to the first instance's federated copy of that account (logged as a warning; older posts may be missing).
- `accounts7d` on trending hashtags is the sum of daily unique accounts, as Mastodon reports it, not unique people across the week.
- Mastodon allows 300 anonymous requests per 5 minutes per IP. The actor waits for the `X-RateLimit-Reset` time if it is ever throttled; at 40 posts per request that is up to 12,000 posts per 5 minutes per server.
- Only public data is collected. Respect the Fediverse's culture and each server's rules; many users do not want their posts used for advertising or AI training.

### FAQ

**Do I need a Mastodon account or token?** No.

**How do I monitor a hashtag every day?** Create a task with your hashtags and `sinceDate` set to yesterday's date (or update it with each schedule), then attach a schedule. Each run stops paging as soon as it reaches older posts.

**Why does a post `url` point to another server?** Posts are federated - the `url` is the post's home, where the canonical version lives. `instance` tells you which server it was read from.

**Can I scrape followers or following lists?** Not in this version.

**How fast is it?** About 1 second per 40 posts. The prefilled run (20 posts) finishes in a few seconds.

# Actor input Schema

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

Hashtag posts, posts from accounts, account profiles, trending posts, or trending hashtags.

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

Hashtag mode: one or more hashtags, with or without the leading #, e.g. ai, opensource, climate. Each hashtag is scraped separately on every instance below.

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

Account and profile modes: accounts as @user@instance, user@instance, or a profile URL like https://fosstodon.org/@kev. Each account is read from its own home server. A bare username is looked up on the first instance below.

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

Mastodon servers to query for hashtag, trending and trending-hashtag modes, e.g. mastodon.social, fosstodon.org, hachyderm.io. Each server only sees posts that reached it, so adding servers widens coverage. Duplicate posts across servers are removed.

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

Stop after this many results for each hashtag-instance pair, each account, or each instance (trending modes).

## `sinceDate` (type: `string`):

Optional. YYYY-MM-DD or an ISO timestamp. Hashtag and account modes stop paginating once posts get older than this, so scheduled runs only pick up what is new.

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

Account mode: skip the account's replies to other posts.

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

Account mode: skip posts the account boosted (reblogged) from others.

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

Hashtag and account modes: keep only posts that have images, video or audio attached.

## `localOnly` (type: `boolean`):

Hashtag mode: return only posts written by users of the queried instance, not posts federated from other servers.

## `proxyConfiguration` (type: `object`):

Optional. A proxy is not required; the Mastodon API is public.

## Actor input object example

```json
{
  "mode": "hashtag",
  "hashtags": [
    "ai"
  ],
  "instances": [
    "mastodon.social"
  ],
  "maxItems": 20,
  "excludeReplies": false,
  "excludeReblogs": false,
  "onlyMedia": false,
  "localOnly": false
}
```

# Actor output Schema

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

All scraped items as JSON.

## `overview` (type: `string`):

Browse results in the Apify Console.

# 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 = {
    "mode": "hashtag",
    "hashtags": [
        "ai"
    ],
    "instances": [
        "mastodon.social"
    ],
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("hichemdev/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 = {
    "mode": "hashtag",
    "hashtags": ["ai"],
    "instances": ["mastodon.social"],
    "maxItems": 20,
}

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

```

## MCP server setup

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