# Mastodon Trending Scraper (`b2b_lead_generation/mastodon-trending-scraper`) Actor

Discover trending posts and hashtags from any Mastodon instance. Collect public social media trends, engagement statistics, and post details, then export structured results as JSON, CSV, Excel, or other dataset formats for research and analysis.

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

## Pricing

from $2.99 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

Discover trending posts and hashtags from Mastodon instances. Collect public social media trends, engagement statistics, post details, and tag information. Choose an instance and collection mode, then export structured results as JSON, CSV, Excel, or other supported dataset formats.

### What It Does

This actor collects trending content from Mastodon instances and saves each result as a separate dataset item. Depending on the selected mode, it gathers trending posts or hashtags, including available identifiers, timestamps, visibility information, engagement counts, and public links.

### Modes

| Mode | Description |
|---|---|
| `statuses` | Collect trending public posts with engagement information. |
| `tags` | Collect trending hashtags, including their names and public links. |

### Input Example

```json
{
  "mode": "statuses",
  "instance": "mastodon.social",
  "maxItems": 40,
  "userAgent": "BigiByteActorResearch/1.0 ()",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

### Input Parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `mode` | string | `statuses` | Selects the collection mode: `statuses` for trending posts or `tags` for trending hashtags. |
| `instance` | string | `mastodon.social` | Mastodon instance hostname to collect trends from, without the URL scheme. |
| `maxItems` | integer | `100` | Maximum number of successful records to collect. |
| `userAgent` | string | b2b lead generation research UA | Identifies the scraper when making requests. |
| `timeoutSecs` | integer | `300` | Overall actor run timeout in seconds. |
| `requestTimeoutSecs` | integer | `30` | Timeout for individual requests in seconds. |
| `proxyConfiguration` | object | No proxy | Optional proxy configuration. |

### What Data Does This Actor Extract?

The actor preserves available Mastodon field names and adds `scrapedAt` to each successful record.

**Example output — Trending post**

```json
{
  "id": "117425715157708337",
  "created_at": "2026-10-12T03:03:38.108Z",
  "in_reply_to_id": null,
  "in_reply_to_account_id": null,
  "sensitive": false,
  "spoiler_text": "",
  "visibility": "public",
  "language": "en",
  "uri": "https://mastodon.social/users/donni/statuses/117425715157708337",
  "url": "https://mastodon.social/@donni/117425715157708337",
  "replies_count": 5,
  "reblogs_count": 72,
  "favourites_count": 146,
  "quotes_count": 0,
  "scrapedAt": "2026-10-12T05:00:00+00:00",
}
```

### Output Fields

| Field | Type | Description |
|---|---|---|
| `id` | string | Mastodon record identifier. Tag names are used when a tag does not have an ID. |
| `created_at` | string | Post creation timestamp. Null for tags. |
| `in_reply_to_id` | string or null | Identifier of the parent post. |
| `in_reply_to_account_id` | string or null | Identifier of the parent account. |
| `sensitive` | boolean | Indicates whether a post is marked as sensitive. |
| `spoiler_text` | string | Post content warning or spoiler text. For tags, contains the tag name. |
| `visibility` | string | Visibility setting of a post. |
| `language` | string | Language code when available. |
| `uri` | string | ActivityPub or tag URI. |
| `url` | string | Public web URL of the post or tag. |
| `replies_count` | integer | Number of replies to a post. |
| `reblogs_count` | integer | Number of reblogs. |
| `favourites_count` | integer | Number of favourites. |
| `quotes_count` | integer | Number of quotes. |
| `scrapedAt` | string | ISO timestamp added when the actor collects the record. |

Fields that do not apply to a particular record type may be null or unavailable.

### Use Cases

- **Fediverse Research:** Explore trending discussions and hashtags across Mastodon communities.
- **Trend Monitoring:** Track popular posts and hashtags through scheduled collections.
- **Content Discovery:** Find public posts receiving engagement for research and analysis.
- **Instance Comparison:** Compare trending topics across different Mastodon servers.
- **Social Media Analysis:** Review engagement counts, post visibility, and language information.
- **Data Integration:** Export structured trends for dashboards, spreadsheets, and research workflows.

### FAQ

**Can I collect trends from different Mastodon instances?**

Yes. Set the `instance` parameter to the hostname of your preferred server. Available trends may vary between instances.

**What is the difference between `statuses` and `tags`?**

`statuses` collects trending posts with engagement information, while `tags` collects trending hashtags and their available details.

**Does it collect engagement statistics?**

Yes. Trending post records can include reply, reblog, favourite, and quote counts.

**Can I schedule recurring collections?**

Yes. Use Apify schedules to collect updated trends automatically at your preferred intervals.

### Trademark Notice

Mastodon is a trademark of its respective owner. This actor is an independent tool and is not affiliated with or endorsed by Mastodon.

### Disclaimer

This actor is provided for public trend discovery and research purposes. Users are responsible for ensuring that their collection and use of posts, hashtags, personal information, and other content comply with applicable laws, licensing requirements, and the policies of the relevant Mastodon instance.

### Is Web Scraping Legal?

This actor collects publicly accessible Mastodon posts and trending hashtags without bypassing login screens, paywalls, or technical security measures. How collected information can be used depends on applicable laws and the policies of the relevant Mastodon instance.

- **Personal Data:** Public posts may contain usernames, account information, and other personal details. Handle such information responsibly and follow applicable privacy regulations, including GDPR and CCPA where relevant.
- **Copyright and Licensing:** Posts, images, videos, and other user-created content may be protected by copyright. Respect content licences, attribution requirements, and creators' rights before reproducing or redistributing material.
- **Platform Terms and Rate Limits:** Respect Mastodon's policies and the terms and usage requirements of the instance being accessed.
- **Disclaimer:** This information is general guidance, not legal advice. Consult a qualified legal professional if you have questions about your intended use.

For more information, read [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/).

# Actor input Schema

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

What to scrape: trending posts (statuses) or trending tags.

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

Mastodon instance host (no scheme). Prefill uses mastodon.social.

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

Stop after this many successful rows. Hard max is 1000.

## `userAgent` (type: `string`):

Identify your scraper to the instance.

## `timeoutSecs` (type: `integer`):

Overall run budget in seconds.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds.

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

Optional proxy. Mastodon public trends usually work without a proxy.

## Actor input object example

```json
{
  "mode": "statuses",
  "instance": "mastodon.social",
  "maxItems": 100,
  "userAgent": "",
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Dataset rows in the overview table.

## `dataset` (type: `string`):

Full dataset for this run.

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

Dataset items as JSON.

# 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 = {
    "instance": "mastodon.social"
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/mastodon-trending-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 = { "instance": "mastodon.social" }

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/mastodon-trending-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 '{
  "instance": "mastodon.social"
}' |
apify call b2b_lead_generation/mastodon-trending-scraper --silent --output-dataset

```

## MCP server setup

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