Mastodon API

Get Mastodon data as clean JSON with one key: 27 endpoints, 1 to 5 credits per call, the same response shape as every other platform.

What you get#

Onekey exposes Mastodon as 27 endpoints behind one API key: 5 endpoints return one record (data is an object) and 22 endpoints return a list (data is an array). Every answer uses the same envelope (success, data, metadata, error), the cost is reported in metadata.credits_charged, and fields are mapped onto the unified schema so the code you write for Mastodon also works for the rest of the social networks category.

Endpoints#

EndpointWhat it doesParametersCreditsStatus
account_by_idFetch a Mastodon account by numeric id (instance-local id).id*, instance1stable
custom_emojisCustom emojis of an instance.instance5stable
directoryProfile directory of an instance.instance5stable
featured_tagsHashtags featured on a Mastodon profile.id*, instance5stable
followersFollowers of a Mastodon account.id*, instance5stable
followingAccounts a Mastodon account follows.id*, instance5stable
hashtagHashtag info and 7-day usage on an instance.tag*, instance1stable
instanceInstance information (v2).instance1stable
instance_activityWeekly activity of an instance.instance5stable
instance_peersDomains an instance federates with (large list).instance5stable
instance_rulesRules of an instance.instance5stable
profileFetch a Mastodon account (default instance mastodon.social).handle*, instance1stable
search_accountsSearch Mastodon accounts.q*, instance5stable
search_hashtagsSearch Mastodon hashtags.q*, instance5stable
statusA single Mastodon post by instance-local id.id*, instance1stable
status_context_repliesReplies to a Mastodon post.id*, instance5stable
status_favourited_byAccounts that favourited a Mastodon post.id*, instance5stable
status_reblogged_byAccounts that boosted a Mastodon post.id*, instance5stable
statusesRecent public posts by a Mastodon account (by instance-local account id).id*, instance5stable
statuses_mediaMedia posts by a Mastodon account.id*, instance5stable
statuses_pinnedPinned posts of a Mastodon account.id*, instance5stable
timeline_localLocal timeline of an instance (anonymous access).instance5stable
timeline_publicFederated public timeline (instances that allow anonymous access).instance5stable
timeline_tagPublic posts for a hashtag.tag*, instance5stable
trends_linksTrending links on an instance.instance5stable
trends_statusesTrending posts on an instance.instance5stable
trends_tagsTrending hashtags on an instance.instance5stable

A * marks a required parameter. Each endpoint name links to its reference page with the full parameter table, caching window and a recorded response.

Make a request#

This calls mastodon.account_by_id (1 credit, stable). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/mastodon/account_by_id?id=1" \
  -H "x-api-key: YOUR_API_KEY"

Fields you get back#

These unified fields come back from Mastodon, with the same names as on every other platform. The count is how many of its 27 mapped endpoints return the field; a field the source lacks is null, never missing. 7 platform-specific fields (ext.<name>) come on top, documented on each endpoint page.

FieldTypeEndpoints
content.textstring19
engagement.commentsinteger19
content.createdAtISO 8601 date18
author.avatarUrlURL17
author.displayNamestring17
author.idstring17
author.urlURL17
author.usernamestring17
content.idstring11
content.languagestring10
content.urlURL10
engagement.likesinteger10
engagement.sharesinteger10
author.followersinteger8
author.followinginteger8
entity.namestring8
entity.urlURL4
content.titlestring2
media.thumbnailUrlURL2
engagement.viewsinteger1
entity.descriptionstring1
media.urlURL1
package.versionstring1

The full schema is in Unified schema.

Pricing#

Mastodon calls cost 1 to 5 credits, flat per endpoint. Free when served from cache (0.2 credit for a cached response over 100 KB). Invalid, failed or not-found calls are not charged. See pricing for credit packs.