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#
| Endpoint | What it does | Parameters | Credits | Status |
|---|---|---|---|---|
account_by_id | Fetch a Mastodon account by numeric id (instance-local id). | id*, instance | 1 | stable |
custom_emojis | Custom emojis of an instance. | instance | 5 | stable |
directory | Profile directory of an instance. | instance | 5 | stable |
featured_tags | Hashtags featured on a Mastodon profile. | id*, instance | 5 | stable |
followers | Followers of a Mastodon account. | id*, instance | 5 | stable |
following | Accounts a Mastodon account follows. | id*, instance | 5 | stable |
hashtag | Hashtag info and 7-day usage on an instance. | tag*, instance | 1 | stable |
instance | Instance information (v2). | instance | 1 | stable |
instance_activity | Weekly activity of an instance. | instance | 5 | stable |
instance_peers | Domains an instance federates with (large list). | instance | 5 | stable |
instance_rules | Rules of an instance. | instance | 5 | stable |
profile | Fetch a Mastodon account (default instance mastodon.social). | handle*, instance | 1 | stable |
search_accounts | Search Mastodon accounts. | q*, instance | 5 | stable |
search_hashtags | Search Mastodon hashtags. | q*, instance | 5 | stable |
status | A single Mastodon post by instance-local id. | id*, instance | 1 | stable |
status_context_replies | Replies to a Mastodon post. | id*, instance | 5 | stable |
status_favourited_by | Accounts that favourited a Mastodon post. | id*, instance | 5 | stable |
status_reblogged_by | Accounts that boosted a Mastodon post. | id*, instance | 5 | stable |
statuses | Recent public posts by a Mastodon account (by instance-local account id). | id*, instance | 5 | stable |
statuses_media | Media posts by a Mastodon account. | id*, instance | 5 | stable |
statuses_pinned | Pinned posts of a Mastodon account. | id*, instance | 5 | stable |
timeline_local | Local timeline of an instance (anonymous access). | instance | 5 | stable |
timeline_public | Federated public timeline (instances that allow anonymous access). | instance | 5 | stable |
timeline_tag | Public posts for a hashtag. | tag*, instance | 5 | stable |
trends_links | Trending links on an instance. | instance | 5 | stable |
trends_statuses | Trending posts on an instance. | instance | 5 | stable |
trends_tags | Trending hashtags on an instance. | instance | 5 | stable |
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.
| Field | Type | Endpoints |
|---|---|---|
content.text | string | 19 |
engagement.comments | integer | 19 |
content.createdAt | ISO 8601 date | 18 |
author.avatarUrl | URL | 17 |
author.displayName | string | 17 |
author.id | string | 17 |
author.url | URL | 17 |
author.username | string | 17 |
content.id | string | 11 |
content.language | string | 10 |
content.url | URL | 10 |
engagement.likes | integer | 10 |
engagement.shares | integer | 10 |
author.followers | integer | 8 |
author.following | integer | 8 |
entity.name | string | 8 |
entity.url | URL | 4 |
content.title | string | 2 |
media.thumbnailUrl | URL | 2 |
engagement.views | integer | 1 |
entity.description | string | 1 |
media.url | URL | 1 |
package.version | string | 1 |
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.