# Mastodon Posts Scraper (`properscraper/mastodon-posts-scraper`) Actor

Export public Mastodon posts by hashtag or by account: text, date, boosts, favourites, replies, media, links and hashtags. Uses the official public Mastodon API of the server you choose, with no login.

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

## Pricing

from $0.30 / 1,000 post saveds

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 Posts Scraper

Export public Mastodon posts by hashtag or by account. For each post you get the text, date, author, boost, favourite and reply counts, media, links, hashtags, mentions and polls.

It uses the official Mastodon API of the server you choose. No login, no cookies and no API key are needed.

Use it to:

- follow a hashtag and see who is posting about a topic
- track what a brand, project, journalist or public figure posts
- measure engagement over time for a set of accounts
- collect posts for research or sentiment analysis

### Input

| Field | What it does |
|---|---|
| **Hashtags and accounts** | One per line: `#opensource`, `@Gargron@mastodon.social`, or a link to a hashtag or profile page. |
| **Server for hashtags** | The server whose view of a hashtag is read. Default `mastodon.social`. |
| **Maximum posts per hashtag or account** | Stop after this many posts for each, newest first. Default 100. |
| **Include replies** | Also return replies to other posts. |
| **Include boosts** | For accounts: also return posts the account boosted. |
| **Only posts with media** | Only posts with an image, video or audio attached. |
| **Posted on or after** | Only posts from this date onwards. |

```json
{
    "sources": ["#opensource", "@Mastodon@mastodon.social", "https://mastodon.social/@Gargron"],
    "server": "mastodon.social",
    "maxPostsPerSource": 500,
    "postedAfter": "2026-01-01"
}
```

### Output

One record per post, newest first:

```json
{
    "source": "@Mastodon@mastodon.social",
    "id": "117599871234567890",
    "url": "https://mastodon.social/@Mastodon/117599871234567890",
    "text": "Mastodon 4.6 is out today.",
    "createdAt": "2026-11-11T14:40:51.440Z",
    "editedAt": null,
    "language": "en",
    "authorHandle": "Mastodon@mastodon.social",
    "authorName": "Mastodon",
    "authorUrl": "https://mastodon.social/@Mastodon",
    "authorFollowers": 850000,
    "authorIsBot": false,
    "isBoost": false,
    "boostedBy": null,
    "boostedAt": null,
    "isReply": false,
    "replyCount": 42,
    "boostCount": 610,
    "favouriteCount": 1280,
    "sensitive": false,
    "contentWarning": null,
    "hashtags": ["mastodon"],
    "mentions": [],
    "media": [{ "type": "image", "url": "https://files.mastodon.social/media_attachments/files/example.png", "description": "Screenshot of the new profile page" }],
    "linkCard": { "url": "https://blog.joinmastodon.org/", "title": "Mastodon 4.6", "description": null },
    "poll": null,
    "server": "mastodon.social",
    "scrapedAt": "2026-11-12T09:00:00.000Z"
}
```

- `source` is the line of input the post was found under.
- For a boost, `isBoost` is `true`, the post and `author` fields describe the original post, and `boostedBy` and `boostedAt` say who boosted it and when.
- `server` is the Mastodon server the post was read from. Counts are the counts that server knows about.

A `SUMMARY` record in the run's key-value store lists, for each hashtag or account, how many posts were saved and any error.

### Pricing

Pay per result. You are charged once for each post saved to the dataset, at the per-result price shown on this page.

Accounts that cannot be found and servers that refuse to answer cost nothing. The run stops as soon as it reaches the maximum charge you set for it.

### Limits

- Mastodon is a network of independent servers. A hashtag timeline holds the posts that the chosen server has seen, which is most but not all posts with that hashtag across the network. A larger server sees more.
- Counts for a post written on another server can be lower than on its home server.
- Only public posts are returned. Followers-only and direct posts are never returned.
- Some servers do not allow reading without a login. Those are reported in the log and the summary.
- The Actor does not search post text by keyword. Mastodon only offers that to logged-in users, and this Actor does not log in.
- Requests are limited to about one a second per server, within Mastodon's published limits. If a server asks the Actor to slow down, it waits.

### Is this allowed?

The Actor uses the public API that Mastodon servers provide for reading public posts without logging in. Posts are returned with the public handle and display name of their author. You are responsible for how you use the data, including any personal data in it and the terms of the server concerned.

# Actor input Schema

## `sources` (type: `array`):

One per line. A hashtag: #opensource. An account: @Gargron@mastodon.social. Or a link to a hashtag or profile page on any Mastodon server.

## `server` (type: `string`):

The Mastodon server whose view of a hashtag is read, and the server assumed for accounts written without one. Larger servers see more posts.

## `maxPostsPerSource` (type: `integer`):

Stop after this many posts for each hashtag or account, newest first.

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

Also return posts that are replies to other posts.

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

For accounts: also return other people's posts that the account boosted. They are marked with "isBoost": true.

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

Only return posts that have an image, video or audio attached.

## `postedAfter` (type: `string`):

Only return posts from this date onwards (YYYY-MM-DD). Reading stops at the first older post, so this also keeps runs short.

## Actor input object example

```json
{
  "sources": [
    "#opensource",
    "@Mastodon@mastodon.social"
  ],
  "server": "mastodon.social",
  "maxPostsPerSource": 100,
  "includeReplies": false,
  "includeBoosts": false,
  "onlyMedia": false
}
```

# Actor output Schema

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

Every post saved by the run, one record per post.

## `summary` (type: `string`):

Totals for the run and, for each hashtag or account, how many results were saved and any error.

# 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 = {
    "sources": [
        "#opensource",
        "@Mastodon@mastodon.social"
    ],
    "server": "mastodon.social"
};

// Run the Actor and wait for it to finish
const run = await client.actor("properscraper/mastodon-posts-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 = {
    "sources": [
        "#opensource",
        "@Mastodon@mastodon.social",
    ],
    "server": "mastodon.social",
}

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

```

## MCP server setup

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