Getting a public timeline

The example below shows how to get the 40 most recent status from the public timeline of the umbracocommunity.social server.

By the default the API will return statuses from all Mastodon servers, but the Local = true will ensure that only statuses from the umbracocommunity.social server are returned.

@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
    MastodonGetPublicTimelineOptions options = new() {
        Limit = 40,
        Local = true
    };

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

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

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

    }

}