# Mastodon Scraper: Posts, Hashtags, Profiles, Trends (`zhtech/mastodon-scraper`) Actor

Scrape public Mastodon posts from hashtags, accounts, timelines, trends and post links on any instance, no login. Text, counts, media, tags, mentions, polls, cards, plus profiles and hashtag stats. Date, language and keyword filters.

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

## Pricing

from $0.28 / 1,000 posts

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 Scraper: posts, hashtags, profiles and trends from any instance

Scrape **public Mastodon posts** from **hashtags, accounts, single post links and threads, local and federated timelines and trending posts**, plus **profile rows** (followers, following, post count, bio, verified links) and **hashtag stats** (uses per day for the last week). Works on **mastodon.social, fosstodon.org, hachyderm.io and any other Mastodon server**, several at once, with duplicates removed.

No login, no access token, no app registration. The actor reads the official public Mastodon REST API that every server offers to logged out visitors, checks each server's robots.txt and timeline settings first, and tells you clearly when a server keeps something for logged in users only. The default run takes about 3 seconds and you only pay for rows you get.

### What can this Mastodon scraper do?

| You give it | You get |
|---|---|
| Hashtags (`opensource`, `#rust`, `rust@fosstodon.org`, a tag link) | Posts with the hashtag, newest first, from every instance you list, deduplicated, plus one hashtag stats row per tag and instance |
| Accounts (`@Mastodon@mastodon.social`, a profile link, a plain username) | One profile row and the account's posts, read on the account's own home server so the full public history is available |
| Post links | The post, and optionally the whole thread (parent posts and public replies) |
| Timelines: local, federated, trending | The instance's public feeds where the server allows logged out access |
| Trending hashtags | Hashtag rows with rank and uses per day |
| Search terms | Matching accounts (profile rows) or hashtags (hashtag rows) |

Fields on every post row: `id`, `url`, `uri`, `createdAt`, `editedAt`, `language`, `visibility`, `sensitive`, `spoilerText`, `text` (plain text with line breaks and full URLs), `contentHtml`, `repliesCount`, `reblogsCount` (boosts), `favouritesCount`, `quotesCount`, `isReply`, `inReplyToId`, `isBoost`, `boostedBy`, `boostedAt`, `authorAcct`, `authorDisplayName`, `authorUrl`, `authorAvatar`, `authorFollowersCount`, `authorFollowingCount`, `authorStatusesCount`, `authorCreatedAt`, `authorBot`, `mediaCount`, `mediaTypes`, `imageUrls`, `videoUrls`, `media` (type, URL, preview, alt text, size, duration), `hashtags`, `mentions`, `links`, `emojis`, `poll`, `card` (link preview), `quote`, `application`, `source`, `instance`, `matchedKeywords`, `scrapedAt`.

### Why this actor

- **Knows which servers allow what.** Mastodon admins decide whether hashtag and live feeds are public. mastodon.social shows hashtags but not the local timeline to logged out visitors, fosstodon.org shows both, mstdn.social shows neither. The actor reads each server's settings and turns a refusal into a clear `AUTH_REQUIRED` row with a suggestion, instead of an empty run. Error rows are free.
- **Accounts read at home.** `@user@fosstodon.org` is read on fosstodon.org, not through another server that only knows the posts it happened to receive. Custom domains are resolved with WebFinger. If a home server cannot be read, the actor falls back to the copy on your first instance and says so in the log.
- **Rich, clean rows.** HTML and plain text side by side, content warnings, alt text for every image, polls with votes, link cards, quotes, edit time, boosts unwrapped to the original post with `boostedBy`, full handles (`user@server`) everywhere.
- **Several instances in one run.** List mastodon.social and fosstodon.org and a hashtag is read on both; posts that federated to both are saved and charged once.
- **Filters that save money.** Dates (also relative, such as `24 hours`), languages, keywords and exclude keywords (checked in text, content warnings, alt text, link cards and polls), no replies, no boosts, media only. Skipped posts are not charged. A newest date jumps straight to that day instead of paging through newer posts.
- **Fediverse friendly.** Honest user agent, robots.txt checked for every server, about 2 requests per second per server (far below the 300 requests per 5 minutes Mastodon allows), and accounts that opted out of indexing (`noindex`, `#nobot`, `#noindex`) are skipped by default and never charged.
- **Fair billing.** Error rows, filtered posts, opted out accounts and duplicates are free. Invalid input stops the run before the start fee.

### Use cases

- **Social listening and brand monitoring**: follow a hashtag or your brand's accounts across several servers every day.
- **Community and developer relations**: see what open source, security or science communities on fosstodon.org, infosec.exchange or scholar.social are talking about.
- **Research**: collect public posts on a topic with dates, languages, boosts and reply threads for discourse or sentiment analysis (follow each server's rules and the authors' rights).
- **Trend tracking**: daily trending hashtags and posts per instance, with uses per day.
- **Influencer and account research**: compare accounts by followers, posting activity and engagement, export verified links from profile fields.
- **Alerts**: schedule a run every hour with **Oldest post date** `1 hour` and a keyword list, and send new matches to Slack, email or a webhook.

### How to use

1. Add **Hashtags**, **Accounts**, **Post URLs** or pick **Timelines**.
2. Set **Instances** for hashtags and timelines (mastodon.social by default; add fosstodon.org for wider coverage).
3. Set **Max posts per source** (newest first) and optionally an **Oldest post date** such as `7 days`.
4. Optionally add **Keywords**, **Languages** or turn off replies or boosts.
5. Click **Start**. Results appear in the **Posts**, **Profiles**, **Hashtags** and **Errors** tabs and can be exported as JSON, CSV, Excel or XML.

### Input examples

The prefilled example (also used when the input is empty): 20 posts with #opensource, 20 posts and the profile of the official Mastodon account, and the hashtag stats row.

```json
{
    "hashtags": ["opensource"],
    "accounts": ["@Mastodon@mastodon.social"],
    "maxPostsPerSource": 20
}
```

A hashtag on two servers, English only, last 7 days:

```json
{
    "instances": ["mastodon.social", "fosstodon.org"],
    "hashtags": ["rust"],
    "languages": ["en"],
    "oldestDate": "7 days",
    "maxPostsPerSource": 500
}
```

Local, federated and trending timelines plus trending hashtags of one server:

```json
{
    "instances": ["fosstodon.org"],
    "timelines": ["local", "federated", "trending"],
    "trendingTags": true,
    "maxPostsPerSource": 40
}
```

One post with its whole conversation:

```json
{
    "postUrls": ["https://mastodon.social/@Mastodon/117466985005297414"],
    "includeThread": true,
    "maxPostsPerSource": 100
}
```

An account's own posts in October 2026, without replies and boosts:

```json
{
    "accounts": ["https://mastodon.social/@MastodonEngineering"],
    "oldestDate": "2026-10-01",
    "newestDate": "2026-10-31",
    "includeReplies": false,
    "includeBoosts": false,
    "maxPostsPerSource": 1000
}
```

Find accounts about a topic:

```json
{
    "searchQueries": ["python"],
    "searchType": "accounts",
    "maxPostsPerSource": 40
}
```

### Output examples

A post row (HTML shortened):

```json
{
    "type": "post",
    "source": "account",
    "input": "@Mastodon@mastodon.social",
    "instance": "mastodon.social",
    "id": "117625790631441803",
    "url": "https://mastodon.social/@Mastodon/117625790631441803",
    "createdAt": "2026-11-16T11:05:27.567Z",
    "editedAt": null,
    "language": "en",
    "visibility": "public",
    "sensitive": false,
    "spoilerText": "",
    "text": "Update on #Plushtodon pre-orders: The plushies are going through German customs on the way to our warehouse ...\n\nhttps://shop.joinmastodon.org/products/pre-order-mastodon-plushie-20cm-plushtodon",
    "contentHtml": "<p>Update on <a href=\"https://mastodon.social/tags/Plushtodon\" ...",
    "repliesCount": 5,
    "reblogsCount": 68,
    "favouritesCount": 134,
    "quotesCount": 0,
    "isReply": false,
    "isBoost": false,
    "boostedBy": null,
    "authorAcct": "Mastodon@mastodon.social",
    "authorDisplayName": "Mastodon",
    "authorUrl": "https://mastodon.social/@Mastodon",
    "authorFollowersCount": 878789,
    "authorStatusesCount": 568,
    "mediaCount": 0,
    "imageUrls": [],
    "videoUrls": [],
    "media": [],
    "hashtags": ["plushtodon"],
    "mentions": [],
    "links": ["https://shop.joinmastodon.org/products/pre-order-mastodon-plushie-20cm-plushtodon"],
    "poll": null,
    "card": {
        "url": "https://shop.joinmastodon.org/products/pre-order-mastodon-plushie-20cm-plushtodon",
        "title": "PRE-ORDER Mastodon plushie 20cm ...",
        "type": "link",
        "image": "https://files.mastodon.social/cache/preview_cards/images/209/240/375/original/ff24843e2838e595.jpg"
    },
    "quote": null,
    "application": "Web",
    "scrapedAt": "2026-11-22T01:55:35.312Z"
}
```

A profile row (shortened):

```json
{
    "type": "profile",
    "source": "account",
    "instance": "mastodon.social",
    "acct": "Mastodon@mastodon.social",
    "displayName": "Mastodon",
    "url": "https://mastodon.social/@Mastodon",
    "bio": "Our mission is to connect the world through thriving online communities. ...",
    "followersCount": 878789,
    "followingCount": 51,
    "statusesCount": 568,
    "lastStatusAt": "2026-11-16",
    "createdAt": "2016-11-23T00:00:00.000Z",
    "bot": false,
    "fields": [{ "name": "Homepage", "value": "https://joinmastodon.org", "url": "https://joinmastodon.org", "verifiedAt": "2018-10-31T04:11:00.076+00:00" }],
    "verifiedLinks": ["https://joinmastodon.org"],
    "avatar": "https://files.mastodon.social/accounts/avatars/000/013/179/original/b4ceb19c9c54ec7e.png"
}
```

A hashtag row:

```json
{
    "type": "hashtag",
    "source": "hashtag",
    "instance": "mastodon.social",
    "name": "opensource",
    "url": "https://mastodon.social/tags/opensource",
    "usesToday": 16,
    "accountsToday": 12,
    "uses7d": 2921,
    "accounts7dSum": 1466,
    "history": [{ "day": "2026-11-22", "uses": 16, "accounts": 12 }, { "day": "2026-11-21", "uses": 372, "accounts": 188 }]
}
```

An error row (never charged):

```json
{
    "type": "error",
    "source": "hashtag",
    "input": "opensource@mstdn.social",
    "errorCode": "AUTH_REQUIRED",
    "error": "mstdn.social only shows hashtag timelines to logged in users (instance setting: authenticated). This actor does not log in. Try the same hashtag on mastodon.social or fosstodon.org, which allow it.",
    "instance": "mstdn.social"
}
```

Error codes: `AUTH_REQUIRED` (the server keeps this feed for logged in users), `NOT_FOUND`, `GONE` (deleted or suspended), `OPTED_OUT` (the account asked not to be indexed), `NOT_MASTODON` (the server does not speak the Mastodon API), `ROBOTS_DISALLOWED`, `RATE_LIMITED`, `INVALID_INPUT`, `FAILED`.

A `RUN_SUMMARY` record in the key value store lists every source with posts saved, posts skipped, pages read and why it stopped, plus each instance's version and timeline access settings.

### Field notes

- **text** is the post converted to plain text: paragraphs become blank lines, line breaks are kept, links keep their full URL, hashtags and mentions stay readable (`#rust`, `@Mastodon`). The original HTML is in `contentHtml`.
- **Boosts** in account timelines are saved as the original post (author, text and counts of the original) with `isBoost: true`, `boostedBy` and `boostedAt`. Turn off **Include boosts** to skip them.
- **Counts** (replies, boosts, favourites) are the numbers the answering server knows. For posts from other servers they can be lower than on the author's home server, which is one reason accounts are read at home.
- **Handles** are always complete (`user@server`), also for users local to the server that answered.
- **Only public and unlisted posts** are returned; Mastodon never shows followers only or direct posts to logged out visitors.
- **Hashtag stats**: `usesToday`, `uses7d` and `history` are the server's own counts of posts and accounts per day.

### Pricing

Pay per event, you only pay for what is delivered:

- **Actor start**: a small flat fee once per run.
- **Post**: per post row.
- **Profile**: per profile row.
- **Hashtag**: per hashtag row (stats, trending or search).

The current prices are on the Pricing tab. Never charged: error rows, posts skipped by your filters, opted out accounts, duplicates across sources and instances, and anything after your max total charge or Max results is reached. Input without any valid source stops the run before the start fee.

Typical runs: the prefilled example is 1 start, 40 posts, 1 profile and 1 hashtag row. A daily hashtag monitor on two servers with 100 new posts a day is about 3,000 posts a month.

### Use with the API, integrations and AI agents

- **API**: `POST https://api.apify.com/v2/acts/zhtech~mastodon-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN` with the JSON input as the body returns the rows in one call. Add `&view=posts` (or `profiles`, `hashtags`, `errors`) for one row type.
- **Clients**: `apify-client` for JavaScript and Python. Example (JavaScript): `await client.actor('zhtech/mastodon-scraper').call({ hashtags: ['rust'], instances: ['fosstodon.org'], oldestDate: '24 hours' })`.
- **Schedules and integrations**: run it hourly or daily with **Oldest post date** and connect Google Sheets, Slack, a webhook, Zapier, Make or n8n.
- **AI agents and MCP**: the actor works as a tool through the Apify MCP server (mcp.apify.com), so assistants such as Claude, ChatGPT or Cursor can look up what a community is saying about a topic or summarize an account's latest posts on demand. Set a max total charge to cap the cost. Note that some servers, including mastodon.social and mastodon.online, forbid using their content for training AI models; respect that.

### FAQ

**Do I need a Mastodon account or an access token?**
No. The actor only calls API endpoints that Mastodon serves to logged out visitors. It never logs in and never sends a token.

**Which servers work?**
Any Mastodon server, and many compatible ones for accounts and posts. What is available depends on each admin's settings: on 2026-11-21, mastodon.social and mastodon.online allowed hashtag feeds and trends but not live timelines, fosstodon.org allowed everything, infosec.exchange allowed only its local timeline, and mstdn.social kept all feeds for logged in users (accounts and posts still work there). The actor checks this on every run and reports it in the error row and the run summary.

**Why did I get AUTH_REQUIRED?**
The server's admin decided that this feed (hashtags, local or federated timeline, trends) is only for logged in users or switched it off. This actor does not log in. Read the same hashtag on another server; mastodon.social and fosstodon.org are good choices because hashtag posts federate widely. The row is free.

**Can I search posts by keyword?**
Mastodon only allows full text search of posts for logged in users, on every server. Use a hashtag or an account as the source and add **Keywords**: the actor keeps only posts that contain your words and charges only those. **Search accounts or hashtags** finds profiles and hashtags by name.

**Why are some accounts skipped with OPTED_OUT?**
Their owners asked search engines not to index them (Mastodon's `noindex` setting) or wrote `#nobot` or `#noindex` in their bio, a common fediverse request to automated tools. The actor respects that by default and does not charge for them. Turn off **Respect account opt outs** only if you have the owner's permission.

**How far back can it go?**
For accounts, the whole public history on the home server. For hashtags and timelines, as far back as the server has posts. Use **Oldest post date** or **Max posts per source** to stop earlier. **Max pages per source** (50 pages of up to 40 posts by default) caps reading when strict filters skip most posts.

**Are boosts, replies and threads included?**
Yes. Boosts are saved as the original post with `boostedBy`. Replies are included unless you turn them off. For a post URL, **Add the whole thread** saves the parent posts and the public replies.

**Do I need a proxy?**
No. The Mastodon API is public and the actor stays far under the rate limit. If a server ever blocks your runs, turn on Apify datacenter proxy. Residential proxy is not supported and is switched to datacenter automatically.

**Is it legal to scrape Mastodon?**
The actor reads only data that servers publish to anyone without login, through their documented API, at a polite rate, after checking robots.txt, and it skips accounts that opted out. Posts belong to their authors. You are responsible for how you use the data, for following each server's rules and privacy laws such as the GDPR, and for not using it for spam, harassment or AI training where a server forbids it.

### Limitations

- No login only content: followers only posts, direct messages, follower lists, notifications and full text post search are not available.
- Server settings decide which feeds are public; the actor reports refusals but cannot work around them.
- Account search and hashtag search return at most 40 results per term and server, because logged out visitors get one page of results.
- Counts are those of the server that answered and can differ slightly between servers.
- Media files are not downloaded; you get their URLs and alt text.
- Non Mastodon fediverse software (Pleroma, Akkoma, GoToSocial, Misskey, Lemmy) is supported only as far as it implements the Mastodon API.

### Support

Found a wrong field, a server that misbehaves, or need another data point? Open an issue on the Issues tab with the input you used and it will be looked at quickly.

# Actor input Schema

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

Hashtags to collect posts from, one per line: opensource, #opensource, a tag link (https://fosstodon.org/tags/opensource) or tag@instance (opensource@fosstodon.org). A plain tag is read on every instance in Instances below. Some servers show hashtag feeds only to logged in users; you then get a clear AUTH_REQUIRED error row (not charged) with a suggestion. If you leave every source field empty (Hashtags, Accounts, Post URLs, Timelines, Search, Trending hashtags), the actor runs this example: opensource plus @Mastodon@mastodon.social.

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

Profiles to read, one per line: @username@instance, a profile link (https://mastodon.social/@Mastodon) or a plain username (read on the first instance below). Each account is read on its own home server, so you get its full public history, not only the posts another server happened to receive.

## `postUrls` (type: `array`):

Single posts by link, for example https://mastodon.social/@Mastodon/123456789012345678. Turn on the option below to also get the whole conversation (replies and parent posts).

## `includeThread` (type: `boolean`):

For each post URL, also save the posts it replies to and the public replies below it (up to Max posts per source).

## `timelines` (type: `array`):

Instance wide feeds, read on every instance below. Local: public posts by the instance's own users. Federated: public posts from other servers the instance knows. Trending: the instance's trending posts right now. Many large servers (mastodon.social included) show the local and federated timelines only to logged in users; fosstodon.org allows both.

## `trendingTags` (type: `boolean`):

Save the instance's trending hashtags with their use counts for the last 7 days (one hashtag row each, up to Max posts per source).

## `searchQueries` (type: `array`):

Search terms for the instance's public search, up to 40 results per term and instance (logged out visitors get one page of results). Mastodon only lets logged in users search the text of posts, so this searches account names and bios, or hashtag names. To find posts by word, use Hashtags or Accounts with the Keywords filter.

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

What the search queries return: profile rows or hashtag rows.

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

Mastodon servers used for hashtags, timelines, trends, search and plain usernames, one domain per line (mastodon.social, fosstodon.org, hachyderm.io). Several instances are read one after another and duplicate posts are saved only once. Accounts and post links always go to their own server.

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

Newest first. Applies to each hashtag on each instance, each account, each timeline and each thread, and to the number of rows per search query or trending list. 0 saves only profile and hashtag rows.

## `includeProfiles` (type: `boolean`):

One extra row for each account in Accounts: display name, bio, followers, following, post count, join date, last post date, profile fields with verified links, avatar and header.

## `includeHashtagStats` (type: `boolean`):

One extra row for each hashtag and instance with uses and accounts per day for the last 7 days.

## `oldestDate` (type: `string`):

Stop when posts get older than this. YYYY-MM-DD (UTC), a full ISO timestamp, or a relative value such as 24 hours, 7 days, 2 weeks. Ideal for scheduled runs: 24 hours every day gives you only new posts.

## `newestDate` (type: `string`):

Skip posts newer than this (not saved, not charged). Same formats; a plain date includes the whole UTC day. The actor jumps straight to this date instead of reading newer pages.

## `languages` (type: `array`):

Keep only posts in these languages, as two letter codes (en, de, fr, ja). Uses the language the author's app set on the post. Leave empty for all.

## `keywords` (type: `array`):

Keep only posts that contain at least one of these words or phrases (case insensitive, checked in the post text, content warning, image descriptions, link card and poll options). Non matching posts are skipped and not charged. Each saved post lists its matchedKeywords.

## `excludeKeywords` (type: `array`):

Skip posts that contain any of these words or phrases. Skipped posts are not charged.

## `keywordMatch` (type: `string`):

Contains: part of a word is enough (rust also matches rusty). Whole word: only complete words or phrases.

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

Turn off to keep only top level posts.

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

Boosts (reposts) in account timelines are saved as the original post with boostedBy and boostedAt filled in. Turn off to keep only the account's own posts.

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

Keep only posts with images, videos, GIFs or audio.

## `respectOptOuts` (type: `boolean`):

Skip accounts that asked search engines not to index them (Mastodon's noindex setting) or that put #nobot or #noindex in their bio. These are skipped and never charged. Keep this on unless you have the account owner's permission.

## `maxPagesPerSource` (type: `integer`):

Safety limit for filtered runs. Each page holds up to 40 posts. With strict filters (rare keywords, a language far from the instance's audience) the actor may read many pages to find matches; this caps it per source.

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

Stop the whole run after this many saved rows (posts, profiles and hashtag rows). 0 means no limit. Your maximum cost per run (set in the run options) is respected as well.

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

Not needed for normal use: the Mastodon API is public and the actor stays far below the limit of 300 anonymous requests per 5 minutes per server. Use Apify datacenter proxy only if a server blocks your runs. Residential proxy is not supported and is replaced by datacenter automatically.

## Actor input object example

```json
{
  "hashtags": [
    "opensource"
  ],
  "accounts": [
    "@Mastodon@mastodon.social"
  ],
  "includeThread": false,
  "timelines": [],
  "trendingTags": false,
  "searchType": "accounts",
  "instances": [
    "mastodon.social"
  ],
  "maxPostsPerSource": 20,
  "includeProfiles": true,
  "includeHashtagStats": true,
  "keywordMatch": "contains",
  "includeReplies": true,
  "includeBoosts": true,
  "onlyMedia": false,
  "respectOptOuts": true,
  "maxPagesPerSource": 50,
  "maxItems": 0,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

## `profiles` (type: `string`):

No description

## `hashtags` (type: `string`):

No description

## `errors` (type: `string`):

No description

## `allResults` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# 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": [
        "opensource"
    ],
    "accounts": [
        "@Mastodon@mastodon.social"
    ],
    "instances": [
        "mastodon.social"
    ],
    "maxPostsPerSource": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("zhtech/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": ["opensource"],
    "accounts": ["@Mastodon@mastodon.social"],
    "instances": ["mastodon.social"],
    "maxPostsPerSource": 20,
}

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

```

## MCP server setup

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