Getting a hashtag timeline

The example below shows how to get the 40 most recent status from the #Umbraco hashtag.

Although this example uses the umbracocommunity.social, the returned status may also come from other Mastodon servers. To only return local statuses, you can add Local = true to the options.

@using Skybrud.Social.Mastodon
@using Skybrud.Social.Mastodon.Options.Timeline
@using Skybrud.Social.Mastodon.Responses.Statuses

@{

    // Initialize a new HTTP service (basically the API wrapper)
    MastodonHttpService mastodon = MastodonHttpService.CreateFromDomain("umbracocommunity.social");

    // Initialize the options for the request to the API
    MastodonGetHashtagTimelineOptions options = new() {
        Hashtag = "umbraco",
        Limit = 40,
        //Local = true
    };

    // Make the request to the API
    MastodonStatusListResponse response = await mastodon
        .Timelines
        .GetHashtagTimelineAsync(options);

    // Iterate through the first 40 statuses
    foreach (var status in response.Body) {

        <pre>@status.CreatedAt - @status.Account.DisplayName - @status.Content</pre>

    }

}