Scraper APIMastodon
mastodon.hashtag
The public posts with a hashtag that a Mastodon server knows, newest first: text, author, time, counts, links and media.
- Id
mastodon.hashtag- Version
- 1
- Billed per
- record — 1 unit for each record of a charged run
- Runs
- within one request
Start it with POST /v1/scrapers/mastodon.hashtag/runs. How runs work is in Running a scraper; what a run costs is in Usage and units.
Inputs
The fields of input. A field that is not listed here is refused.
| Field | Type | Description |
|---|---|---|
tagrequired | string | The hashtag, with or without the #, e.g. photography.Limit: at most 101 characters. |
server | string | The Mastodon server to ask, by its domain. Each server knows the posts that reached it.Limit: at most 253 characters. Default: "mastodon.social". |
local | boolean | True keeps only the posts of the server's own users.Default: false. |
max_posts | integer | How many posts to return, newest first: 1 to 200.Limit: 1 to 200. Default: 40. |
cursor | string | Continue an earlier run: the next_cursor it reported.Limit: matches ^[0-9]{1,20}$. |
Record fields
Every record of a run has these fields. A value that is not known is null — never an empty string and never 0.
| Field | Type | Notes |
|---|---|---|
id | string | The post's id on the server that answered. |
uri | string or null | The post's permanent id on the network, on the server it was written on. |
url | string or null | The post's address on the web. |
server | string | The server that answered, e.g. mastodon.social. |
text | string or null | The post's text, links written out; null for a post that is only media. |
content_warning | string or null | The warning the author put in front of the text, when there is one. |
sensitive | boolean | True when the author marked the media as sensitive.Default: false. |
language | string or null | The language the post is marked with, e.g. en. |
visibility | string or null | public or unlisted: the only posts a visitor who is not signed in is shown. |
created_at | string (date-time) or null | When it was posted, in UTC. |
edited_at | string (date-time) or null | When it was last edited, in UTC; null when it never was. |
author_acct | string or null | The author's full address, user@server. |
author_name | string or null | The author's display name. |
author_url | string or null | The author's profile address. |
author_bot | boolean or null | True when the author's account says it is automated. |
reply_count | integer or null | Number of replies the answering server knows of. |
boost_count | integer or null | Number of boosts (reposts) the answering server knows of. |
favourite_count | integer or null | Number of favourites the answering server knows of. |
quote_count | integer or null | Number of posts that quote this one; null where the server does not say. |
hashtags | array of string | The hashtags of the post, without the #, lower case. |
mentions | array of string | The accounts the post mentions, as user@server. |
links | array of string | The full addresses of the links in the text, in order, without mentions and hashtags. |
media | array of object | The post's images, videos and audio, in order. |
type (in media[]) | "image" | "video" | "gifv" | "audio" | image, video, gifv (a short looping video without sound) or audio. |
url (in media[]) | string | The file at full size. |
preview_url (in media[]) | string or null | A smaller image of it. |
alt_text (in media[]) | string or null | The description the author gave it, when there is one. |
width (in media[]) | integer or null | Width in pixels. |
height (in media[]) | integer or null | Height in pixels. |
duration_s (in media[]) | number or null | Length in seconds, for a video or audio. |
link_card | object or null | The preview card of a link in the post, when the server made one. |
url (in link_card) | string | The address the card leads to. |
title (in link_card) | string or null | The card's title. |
description (in link_card) | string or null | The card's text. |
image_url (in link_card) | string or null | The card's image. |
provider (in link_card) | string or null | The site the link is on, as the card names it. |
poll | object or null | The post's poll, when it has one. |
options (in poll) | array of object | The options, in order. |
title (in poll.options[]) | string | The option's text. |
votes (in poll.options[]) | integer or null | Votes for it; null while the poll hides its results. |
votes (in poll) | integer or null | Votes cast in all. |
voters (in poll) | integer or null | Accounts that voted; null when the server does not say. |
multiple (in poll) | boolean or null | True when a voter may pick more than one option. |
expires_at (in poll) | string (date-time) or null | When the poll closes or closed, in UTC. |
expired (in poll) | boolean or null | True when it has closed. |
quoted_post_url | string or null | The address of the post this one quotes, when it quotes one. |
reply_to_id | string or null | The id, on the answering server, of the post this one replies to; null when it is not a reply. |
boosted_by_acct | string or null | In an account's posts: the account that boosted this post, when it is listed as a boost. |
boosted_at | string (date-time) or null | When it was boosted, in UTC. |
fetched_at | string (date-time) | When the answer was read, in UTC. |
Example request
# Start a run and wait up to 60 seconds for it to finish
curl -X POST "https://api.enrichednow.com/v1/scrapers/mastodon.hashtag/runs?wait=60" \
-H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input":{"tag":"photography","server":"mastodon.social","max_posts":3}}'
# Read its records, with the id the first call answered
curl "https://api.enrichednow.com/v1/runs/$RUN_ID/records?limit=100" \
-H "Authorization: Bearer $ENRICHEDNOW_API_KEY"from enrichednow import EnrichedNow
client = EnrichedNow() # reads ENRICHEDNOW_API_KEY
# Start a run, wait for it to end, and get its records
result = client.scrape("mastodon.hashtag", {
"tag": "photography",
"server": "mastodon.social",
"max_posts": 3,
})
print(result.run.id, result.run.status, result.run.record_count)
# Read its records: pages are fetched as you go
for record in result.records:
print(record)Install it with pip install enrichednow, then save as run.py and run python3 run.py
import EnrichedNow from "enrichednow";
const client = new EnrichedNow(); // reads ENRICHEDNOW_API_KEY
// Start a run, wait for it to end, and get its records
const { run, records } = await client.scrape("mastodon.hashtag", {
tag: "photography",
server: "mastodon.social",
max_posts: 3,
});
console.log(run.id, run.status, run.record_count);
// Read its records: pages are fetched as you go
for await (const record of records) console.log(record);Install it with npm install enrichednow, then save as run.mjs and run node run.mjs
package main
import (
"context"
"fmt"
"log"
"time"
enrichednow "github.com/enrichednow/enrichednow-go"
)
func main() {
client, err := enrichednow.NewClient() // reads ENRICHEDNOW_API_KEY
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
// Start a run, wait for it to end, and get its records
run, records, err := client.Scrape(ctx, "mastodon.hashtag", map[string]any{"tag": "photography", "server": "mastodon.social", "max_posts": 3})
if err != nil {
log.Fatal(err)
}
fmt.Println(run.ID, run.Status, run.RecordCount)
// Read its records: pages are fetched as you go
for records.Next() {
fmt.Println(string(records.Current()))
}
if err := records.Err(); err != nil {
log.Fatal(err)
}
}Install it with go get github.com/enrichednow/enrichednow-go@latest, then save as run.go and run go run run.go
import com.enrichednow.EnrichedNowClient;
import com.enrichednow.ScrapeResult;
import java.util.Map;
public class Run {
public static void main(String[] args) {
EnrichedNowClient client = EnrichedNowClient.fromEnv(); // reads ENRICHEDNOW_API_KEY
// Start a run, wait for it to end, and get its records
ScrapeResult result = client.scrape("mastodon.hashtag", Map.of("tag", "photography", "server", "mastodon.social", "max_posts", 3));
System.out.println(result.run().id() + " " + result.run().status() + " " + result.run().recordCount());
// Read its records: pages are fetched as you go
for (Map<String, Object> record : result.records()) {
System.out.println(record);
}
}
}Add com.enrichednow:enrichednow-java:0.4.0 to your Maven or Gradle build, then save as Run.java
enrichednow run mastodon.hashtag --input tag=photography --input server=mastodon.social --input max_posts=3Install it with curl -fsSL https://raw.githubusercontent.com/enrichednow/enrichednow-cli/main/install.sh | sh
It starts a run with this scraper’s example input, waits for it to finish and reads its records a page at a time. The key is read from ENRICHEDNOW_API_KEY.
The body on its own:
{
"input": {
"tag": "photography",
"server": "mastodon.social",
"max_posts": 3
}
}Example response
The run, once it has ended. A run that has not ended within wait comes back with 202 and the status queued or running.
{
"id": "run_841742f37553189ff9c27ba1",
"scraper_id": "mastodon.hashtag",
"scraper_version": 1,
"status": "ok",
"reason": null,
"input": {
"tag": "photography",
"server": "mastodon.social",
"max_posts": 3
},
"record_count": 1,
"units": 1,
"units_per_request": null,
"units_per_record": 1,
"units_per_page": null,
"diagnostics": {
"requests": 1,
"bytes": 259214,
"wall_ms": 885,
"facts": {}
},
"created_at": "2026-11-16T22:37:50.170950Z",
"started_at": "2026-11-16T22:37:50.178331Z",
"finished_at": "2026-11-16T22:37:51.066313Z"
}Its records, from GET /v1/runs/{id}/records. The record is a real one: this scraper's own parser read it from a page recorded from the site.
{
"records": [
{
"id": "117643991074630878",
"uri": "https://mastodon.social/ap/users/116974345190651099/statuses/117643991074630878",
"url": "https://example.com/@person-1/117643991074630878",
"server": "mastodon.social",
"text": "Dinner table\n#photo #photography #photos #blackandwhite",
"content_warning": null,
"sensitive": false,
"language": "de",
"visibility": "public",
"created_at": "2026-11-19T16:14:04.303000Z",
"edited_at": null,
"author_acct": null,
"author_name": null,
"author_url": null,
"author_bot": false,
"reply_count": 0,
"boost_count": 0,
"favourite_count": 0,
"quote_count": 0,
"hashtags": [
"photo",
"photography",
"photos"
],
"mentions": [],
"links": [],
"media": [
{
"type": "image",
"url": "https://files.mastodon.social/media_attachments/files/117/643/987/629/877/224/original/b07d72948beec6ef.jpg",
"preview_url": "https://files.mastodon.social/media_attachments/files/117/643/987/629/877/224/small/b07d72948beec6ef.jpg",
"alt_text": null,
"width": 2494,
"height": 3325,
"duration_s": null
}
],
"link_card": null,
"poll": null,
"quoted_post_url": null,
"reply_to_id": null,
"boosted_by_acct": null,
"boosted_at": null,
"fetched_at": "2026-11-19T18:07:40.959186Z"
}
],
"next_cursor": null
}What was done to the record for this page, and nothing else — the API returns every value whole. A text that was cut ends with … [truncated].
- Shortened:
hashtags: 4 items, the first 3 shown. - Left out:
author_acct: the author is a person (a stand-in in the fixture); a run returns the address the post shows. - Left out:
author_url: the author's profile address; a run returns it. - Left out:
author_name: the author's display name; a run returns it.
A run does not always end ok. Results and statuses lists every status and the reasons every scraper shares; the reasons of the Mastodon scrapers are in their own section there.