Complete account operations including profiles, relationships, and social actions.
type Account struct {
ID ID
Username string
Acct string
DisplayName string
Locked bool
CreatedAt time.Time
FollowersCount int64
FollowingCount int64
StatusesCount int64
Note string
URL string
Avatar string
AvatarStatic string
Header string
HeaderStatic string
Emojis []Emoji
Moved *Account
Fields []Field
Bot bool
Discoverable bool
Source *AccountSource
FollowedTag []FollowedTag
}Account holds information for a mastodon account.
Fields:
ID - Unique account identifierUsername - Local username without domainAcct - Full username with domain (e.g., user@domain.com)DisplayName - Display name shown on profileLocked - Whether account requires follow approvalCreatedAt - Account creation timestampFollowersCount - Number of followersFollowingCount - Number of accounts followedStatusesCount - Number of statuses postedNote - Profile bio/description (HTML)URL - Profile URLAvatar - Avatar image URLAvatarStatic - Static avatar URL (non-animated)Header - Header image URLHeaderStatic - Static header URLEmojis - Custom emojis used in profileMoved - New account if account has movedFields - Profile metadata fieldsBot - Whether this is a bot accountDiscoverable - Whether account appears in discovery featuresSource - Private account settings (only for own account)FollowedTag - Tags followed by this accounttype AccountSource struct {
Privacy *string
Sensitive *bool
Language *string
Note *string
Fields *[]Field
}AccountSource is a Mastodon account profile field containing private settings.
Fields:
Privacy - Default post visibility ("public", "unlisted", "private", "direct")Sensitive - Whether to mark posts as sensitive by defaultLanguage - Default posting language codeNote - Raw profile bio (plain text)Fields - Profile metadata fieldstype Field struct {
Name string
Value string
VerifiedAt time.Time
}Field is a Mastodon account profile field (custom metadata displayed on profile).
Fields:
Name - Field label (e.g., "Website", "Pronouns")Value - Field value (HTML, may contain links)VerifiedAt - Timestamp when field link was verified (zero if not verified)type Profile struct {
DisplayName *string
Note *string
Locked *bool
Fields *[]Field
Source *AccountSource
Avatar string
Header string
}Profile is a struct for updating user profiles. Nil pointer fields are not updated, empty strings/values update to empty.
Fields:
DisplayName - New display name (nil = no change, empty = clear)Note - New bio text (nil = no change, empty = clear)Locked - Require follow approval (nil = no change)Fields - Profile metadata fields (nil = no change)Source - Account source settings (nil = no change)Avatar - Base64 encoded image string for new avatarHeader - Base64 encoded image string for new headertype Relationship struct {
ID ID
Following bool
FollowedBy bool
Blocking bool
Muting bool
MutingNotifications bool
Requested bool
DomainBlocking bool
ShowingReblogs bool
Endorsed bool
}Relationship holds information for relationship to another account.
Fields:
ID - Target account IDFollowing - Whether you follow this accountFollowedBy - Whether this account follows youBlocking - Whether you block this accountMuting - Whether you mute this accountMutingNotifications - Whether you mute notifications from this accountRequested - Whether you have a pending follow requestDomainBlocking - Whether you block this account's domainShowingReblogs - Whether you see this account's reblogsEndorsed - Whether you endorse/feature this accountfunc (c *Client) GetAccount(ctx context.Context, id ID) (*Account, error)Returns account by ID.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to retrieveReturns: Account information or error
Example:
account, err := client.GetAccount(ctx, "123456")
if err != nil {
log.Fatal(err)
}
fmt.Printf("@%s: %s\n", account.Acct, account.DisplayName)func (c *Client) GetAccountCurrentUser(ctx context.Context) (*Account, error)Returns the current user's account information.
Parameters:
ctx - Context for cancellation/timeoutReturns: Current user's Account or error
Example:
me, err := client.GetAccountCurrentUser(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Logged in as: %s\n", me.Acct)func (c *Client) AccountLookup(ctx context.Context, acct string) (*Account, error)Returns account by acct URI (username@domain format).
Parameters:
ctx - Context for cancellation/timeoutacct - Account URI (e.g., user@mastodon.social)Returns: Account information or error
Example:
account, err := client.AccountLookup(ctx, "gargron@mastodon.social")
if err != nil {
log.Fatal(err)
}func (c *Client) AccountUpdate(ctx context.Context, profile *Profile) (*Account, error)Updates the current user's profile information.
Parameters:
ctx - Context for cancellation/timeoutprofile - Profile updates (nil fields are not changed)Returns: Updated Account or error
Example:
displayName := "New Display Name"
note := "Updated bio"
profile := &mastodon.Profile{
DisplayName: &displayName,
Note: ¬e,
}
account, err := client.AccountUpdate(ctx, profile)
if err != nil {
log.Fatal(err)
}func (c *Client) GetAccountStatuses(ctx context.Context, id ID, pg *Pagination) ([]*Status, error)Returns statuses posted by the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account IDpg - Pagination parameters (optional, nil for defaults)Returns: Slice of Status objects or error
func (c *Client) GetAccountPinnedStatuses(ctx context.Context, id ID) ([]*Status, error)Returns statuses pinned by the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account IDReturns: Slice of pinned Status objects or error
func (c *Client) GetAccountFollowers(ctx context.Context, id ID, pg *Pagination) ([]*Account, error)Returns the account's followers list.
Parameters:
ctx - Context for cancellation/timeoutid - Account IDpg - Pagination parameters (optional)Returns: Slice of follower Account objects or error
func (c *Client) GetAccountFollowing(ctx context.Context, id ID, pg *Pagination) ([]*Account, error)Returns the account's following list.
Parameters:
ctx - Context for cancellation/timeoutid - Account IDpg - Pagination parameters (optional)Returns: Slice of followed Account objects or error
func (c *Client) GetAccountRelationships(ctx context.Context, ids []string) ([]*Relationship, error)Returns relationships for the specified account IDs.
Parameters:
ctx - Context for cancellation/timeoutids - Slice of account ID stringsReturns: Slice of Relationship objects or error
Example:
rels, err := client.GetAccountRelationships(ctx, []string{"123", "456", "789"})
if err != nil {
log.Fatal(err)
}
for _, rel := range rels {
fmt.Printf("Account %s: following=%v, followed_by=%v\n",
rel.ID, rel.Following, rel.FollowedBy)
}func (c *Client) GetAccountLists(ctx context.Context, id ID) ([]*List, error)Returns lists containing the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account IDReturns: Slice of List objects containing this account or error
func (c *Client) AccountFollow(ctx context.Context, id ID) (*Relationship, error)Follows the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to followReturns: Updated Relationship or error
func (c *Client) AccountUnfollow(ctx context.Context, id ID) (*Relationship, error)Unfollows the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to unfollowReturns: Updated Relationship or error
func (c *Client) FollowRemoteUser(ctx context.Context, uri string) (*Account, error)Sends a follow request to a remote user by URI.
Parameters:
ctx - Context for cancellation/timeouturi - Remote user URI (e.g., user@remote.instance)Returns: Account information or error
func (c *Client) GetFollowRequests(ctx context.Context, pg *Pagination) ([]*Account, error)Returns pending follow requests for locked accounts.
Parameters:
ctx - Context for cancellation/timeoutpg - Pagination parameters (optional)Returns: Slice of Account objects with pending requests or error
func (c *Client) FollowRequestAuthorize(ctx context.Context, id ID) errorAuthorizes a follow request.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID of requesterReturns: Error if operation fails
func (c *Client) FollowRequestReject(ctx context.Context, id ID) errorRejects a follow request.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID of requesterReturns: Error if operation fails
func (c *Client) AccountBlock(ctx context.Context, id ID) (*Relationship, error)Blocks the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to blockReturns: Updated Relationship or error
func (c *Client) AccountUnblock(ctx context.Context, id ID) (*Relationship, error)Unblocks the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to unblockReturns: Updated Relationship or error
func (c *Client) GetBlocks(ctx context.Context, pg *Pagination) ([]*Account, error)Returns the block list for the current user.
Parameters:
ctx - Context for cancellation/timeoutpg - Pagination parameters (optional)Returns: Slice of blocked Account objects or error
func (c *Client) AccountMute(ctx context.Context, id ID) (*Relationship, error)Mutes the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to muteReturns: Updated Relationship or error
func (c *Client) AccountUnmute(ctx context.Context, id ID) (*Relationship, error)Unmutes the specified account.
Parameters:
ctx - Context for cancellation/timeoutid - Account ID to unmuteReturns: Updated Relationship or error
func (c *Client) GetMutes(ctx context.Context, pg *Pagination) ([]*Account, error)Returns the list of muted accounts for the current user.
Parameters:
ctx - Context for cancellation/timeoutpg - Pagination parameters (optional)Returns: Slice of muted Account objects or error
func (c *Client) AccountsSearch(ctx context.Context, q string, limit int64) ([]*Account, error)Searches for accounts matching the query.
Parameters:
ctx - Context for cancellation/timeoutq - Search query stringlimit - Maximum number of results (0 for default)Returns: Slice of matching Account objects or error
Example:
accounts, err := client.AccountsSearch(ctx, "mastodon", 20)
if err != nil {
log.Fatal(err)
}
for _, account := range accounts {
fmt.Printf("@%s: %s\n", account.Acct, account.DisplayName)
}func (c *Client) AccountsSearchResolve(ctx context.Context, q string, limit int64, resolve bool) ([]*Account, error)Searches for accounts with optional remote resolution.
Parameters:
ctx - Context for cancellation/timeoutq - Search query stringlimit - Maximum number of results (0 for default)resolve - Whether to resolve remote accounts via WebFingerReturns: Slice of matching Account objects or error
func (c *Client) GetEndorsements(ctx context.Context, pg *Pagination) ([]*Account, error)Returns accounts currently featured on the user's profile.
Parameters:
ctx - Context for cancellation/timeoutpg - Pagination parameters (optional)Returns: Slice of endorsed Account objects or error
func (c *Client) GetFollowedTags(ctx context.Context, pg *Pagination) ([]*FollowedTag, error)Returns the list of hashtags followed by the user.
Parameters:
ctx - Context for cancellation/timeoutpg - Pagination parameters (optional)Returns: Slice of FollowedTag objects or error
See also: