Class: MastodonServer

MastodonServer(domain)

Class for interacting with the public non-authenticated API of a Mastodon server. Provides methods to fetch trending toots, tags, links, and server info, as well as utilities for aggregating and processing trending data across multiple servers in the fediverse.

Constructor

new MastodonServer(domain)

Constructs a MastodonServer instance for the given domain.
Parameters:
Name Type Description
domain string The domain of the Mastodon server.
Properties:
Name Type Description
domain string The domain of the server this MastodonServer object interacts with.
logger Logger Logger instance for this server.

Methods

(async) fetchServerInfo() → {Promise.<InstanceResponse>}

Fetch the mastodon.v2.Instance object (MAU, version, languages, rules, etc) for this server.
Returns:
The instance info or null if not available.
Type
Promise.<InstanceResponse>

Get the links that are trending on this server.
Returns:
Array of trending links.
Type
Promise.<Array.<TrendingLink>>

(async) fetchTrendingStatuses() → {Promise.<Array.<Toot>>}

Fetch toots that are trending on this server. Note: Returned toots have not had setDependentProps() called yet. TODO: should return SerializableToot[] instead of mastodon.v1.Status but the type system is annoying.
Returns:
Array of trending Toot objects.
Type
Promise.<Array.<Toot>>

(async) fetchTrendingTags() → {Promise.<Array.<TagWithUsageCounts>>}

Get the tags that are trending on this server.
Returns:
Array of trending tags with usage counts.
Type
Promise.<Array.<TagWithUsageCounts>>

Get the top trending links from all servers in the fediverse.
Returns:
Array of trending links across all servers.
Type
Promise.<Array.<TrendingLink>>

(async, static) fediverseTrendingTags() → {Promise.<TagList>}

Get the top trending tags from all servers, minus any invalid or muted tags.
Returns:
TagList of trending tags across all servers.
Type
Promise.<TagList>

(async, static) fediverseTrendingToots() → {Promise.<Array.<Toot>>}

Pull public top trending toots on popular mastodon servers including from accounts user doesn't follow.
Returns:
Array of trending Toots across all servers.
Type
Promise.<Array.<Toot>>

(async, static) getMastodonInstancesInfo() → {Promise.<MastodonInstances>}

Get the server names that are most relevant to the user (appears in follows a lot, mostly).
Returns:
Dictionary of MastodonInstances keyed by domain.
Type
Promise.<MastodonInstances>

(async, static) getTrendingData() → {Promise.<TrendingData>}

Collect all three kinds of trending data (links, tags, toots) in one call.
Returns:
Object containing trending links, tags, toots, and servers.
Type
Promise.<TrendingData>