# Scrape Mastodon posts by hashtag

**Use case:** 

Collects recent public Mastodon posts for a hashtag (here: #ai) from several large instances (mastodon.social, fosstodon.org, mastodon.online) with post text, author, timestamp, boosts, favourites, replies, tags, media and the post URL. Use it for social listening, research datasets and trend tracking across the fediverse.

## Input

```json
{
  "mode": "hashtagPosts",
  "hashtags": [
    "ai"
  ],
  "instances": [
    "mastodon.social",
    "fosstodon.org",
    "mastodon.online"
  ],
  "lemmyInstances": [
    "lemmy.world"
  ],
  "maxItemsPerInput": 150,
  "maxItems": 150,
  "excludeReplies": false,
  "excludeBoosts": true,
  "onlyMedia": false,
  "lemmySort": "New",
  "lemmySearchType": "Posts",
  "extractContacts": false,
  "skipNsfw": true,
  "respectNoIndex": true
}
```

## Output

```json
{
  "platform": {
    "label": "Network"
  },
  "url": {
    "label": "Link",
    "format": "link"
  },
  "authorAcct": {
    "label": "Mastodon author"
  },
  "author": {
    "label": "Lemmy author"
  },
  "title": {
    "label": "Lemmy title"
  },
  "text": {
    "label": "Text"
  },
  "body": {
    "label": "Lemmy body"
  },
  "community": {
    "label": "Community"
  },
  "createdAt": {
    "label": "Created",
    "format": "date"
  },
  "favouritesCount": {
    "label": "Favourites",
    "format": "number"
  },
  "boostsCount": {
    "label": "Boosts",
    "format": "number"
  },
  "repliesCount": {
    "label": "Replies",
    "format": "number"
  },
  "score": {
    "label": "Score",
    "format": "number"
  },
  "commentsCount": {
    "label": "Comments",
    "format": "number"
  },
  "hashtags": {
    "label": "Hashtags",
    "format": "array"
  },
  "sourceInput": {
    "label": "Input"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The Mastodon & Lemmy Scraper: Fediverse Posts, Profiles, Comments Actor is ready to run with the inputs already set for "Scrape Mastodon posts by hashtag". [Sign up or log in](https://console.apify.com/create-task-from-example/ppRUr6Cfwo0rlNgCy) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Scrape Mastodon posts by hashtag" task

The Mastodon & Lemmy Scraper: Fediverse Posts, Profiles, Comments Actor will start running based on the input automatically. You can also change all the input fields, like what to scrape, hashtags, and more, to match your specific use case.

### 3. Receive the "Scrape Mastodon posts by hashtag" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as network, link, mastodon author, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "Scrape Mastodon posts by hashtag" task via API](https://apify.com/spriggs-data/fediverse-scraper.md).

## FAQ

### Where does the Mastodon hashtag data come from?

The task reads each instance's public Mastodon API hashtag timeline. It needs no account and only collects public posts, skipping accounts that opted out of indexing.

### Why scrape several Mastodon instances?

Each Mastodon server only sees the posts it federates, so querying several large instances gives a fuller picture of a hashtag. Add or remove servers in the Instances field.

### Can I track a different hashtag or language?

Yes. Change Hashtags to any tag without the # sign, set Language (for example en) and Since to a date, then schedule the task to run daily.

### How much does the Mastodon hashtag task cost?

The Fediverse Scraper Actor charges per result (about $0.50 per 1,000 on the free plan), so 150 posts cost under 10 cents.

## About this Actor

This example demonstrates how to use [Mastodon & Lemmy Scraper: Fediverse Posts, Profiles, Comments](https://apify.com/spriggs-data/fediverse-scraper.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/spriggs-data/fediverse-scraper.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

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 full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/spriggs-data/fediverse-scraper.md

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`).
