TootClient

public class TootClient : @unchecked Sendable
extension TootClient: Equatable

Undocumented

Public properties

  • The URL of the instance we’re connected to

    Declaration

    Swift

    public var instanceURL: URL
  • The application info retrieved from the instance

    Declaration

    Swift

    public var currentApplicationInfo: TootApplication?
  • Set this to true to see a print() of outgoing requests.

    Declaration

    Swift

    public var debugRequests: Bool
  • Set this to true to see a print() of request response.

    Declaration

    Swift

    public var debugResponses: Bool
  • Set this to true to see a print() for instance information.

    Declaration

    Swift

    public var debugInstance: Bool
  • The preferred fediverse server flavour to use for API calls

    Declaration

    Swift

    public var flavour: TootSDKFlavour
  • The authorization scopes the client was initialized with

    Declaration

    Swift

    public let scopes: [String]
  • Data streams that the client can subscribe to

    Declaration

    Swift

    public lazy var data: TootDataStream { get set }
  • The clientName the client was initialized with

    Declaration

    Swift

    public let clientName: String

Internal properties

  • Initialize a new instance of TootClient by optionally providing an access token for authentication.

    After initializing, you need to manually call connect() in order to obtain the correct flavour of the server.

    Declaration

    Swift

    public init(clientName: String = "TootSDK",
                session: URLSession = URLSession.shared,
                instanceURL: URL,
                accessToken: String? = nil,
                scopes: [String] = ["read", "write", "follow", "push"])

    Parameters

    clientName

    Name of the client to be used in outgoing HTTP requests. Defaults to TootSDK

    session

    the URLSession being used internally, defaults to shared

    instanceURL

    the instance you are connecting to

    accessToken

    the existing access token; if you already have one

    scopes

    An array of authentication scopes, defaults to "read", "write", "follow", "push"

  • Initialize and connect a new instance of TootClient.

    The initializer calls connect() internally in order to detect the server flavour.

    Declaration

    Swift

    public init(connect instanceURL: URL,
                clientName: String = "TootSDK",
                session: URLSession = URLSession.shared,
                accessToken: String? = nil,
                scopes: [String] = ["read", "write", "follow", "push"]) async throws

    Parameters

    instanceURL

    the instance you are connecting to

    clientName

    Name of the client to be used in outgoing HTTP requests. Defaults to TootSDK

    session

    the URLSession being used internally, defaults to shared

    accessToken

    the existing access token; if you already have one

    scopes

    An array of authentication scopes, defaults to "read", "write", "follow", "push"

  • Prints extra debug details like outgoing requests and responses

    Declaration

    Swift

    public func debugOn()
  • Stops printing debug details

    Declaration

    Swift

    public func debugOff()
  • Presents a authentication/authorization page using ASWebAuthenticationSession. When signIn is initiated on supported platforms, the authorization web page will be presented in a system-dependent manner that negates the need for user’s to implement a custom web view. Upon successful authentication (or cancellation), control will be return to this function to handle token retrieval.

    Declaration

    Swift

    @MainActor
    public func presentSignIn(callbackURI: String,
                              prefersEphemeralWebBrowserSession: Bool = true,
                              presentationContextProvider: ASWebAuthenticationPresentationContextProviding? = nil) async throws -> String

    Parameters

    callbackURI

    The callback URI (redirect_uri) which was used to initiate the authorization flow. Must match one of the redirect_uris declared during app registration.

    prefersEphemeralWebBrowserSession

    A Boolean value that indicates whether the session should ask the browser for a private authentication session.

    presentationContextProvider

    A delegate that provides a display context in which the system can present an authentication session to the user.

    Return Value

    The auth token for the user if authentication succeeds.

  • verifyCredentials() Asynchronous

    A test to make sure that the user token works, and retrieves the account information

    Declaration

    Swift

    public func verifyCredentials() async throws -> Account

    Return Value

    Returns the current authenticated user’s account, or throws an error if unable to retrieve

  • Update the user’s display and preferences.

    Declaration

    Swift

    public func updateCredentials(params: UpdateCredentialsParams) async throws -> Account

    Return Value

    The user’s own Account with source attribute

  • getAccount(by:) Asynchronous

    View information about a profile.

    Declaration

    Swift

    public func getAccount(by id: String) async throws -> Account

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the account requested, or an error if unable to retrieve

  • Get all accounts which follow the given account, if network is not hidden by the account owner.

    Declaration

    Swift

    public func getFollowers(for id: String, _ pageInfo: PagedInfo? = nil, limit: Int? = nil)
    async throws -> PagedResult<[Account]>

    Return Value

    the accounts requested, or an error if unable to retrieve

  • Get all accounts which the given account is following, if network is not hidden by the account owner.

    Declaration

    Swift

    public func getFollowing(for id: String, _ pageInfo: PagedInfo? = nil, limit: Int? = nil)
    async throws -> PagedResult<[Account]>

    Parameters

    id

    the ID of the Account in the instance database.

    pageInfo

    PagedInfo object for max/min/since

    limit

    Maximum number of results to return. Defaults to 40 accounts. Max 80 accounts.

    Return Value

    the accounts requested, or an error if unable to retrieve

  • Attempts to register a user.

    Returns an account access token for the app that initiated the request. The app should save this token for later, and should wait for the user to confirm their account by clicking a link in their email inbox.

    Declaration

    Swift

    public func registerAccount(params: RegisterAccountParams) async throws -> AccessToken
  • Search for matching accounts by username or display name.

    Declaration

    Swift

    public func searchAccounts(params: SearchAccountsParams, limit: Int? = nil, offset: Int? = nil)
    async throws -> [Account]

    Parameters

    params

    The search parameters.

    limit

    Maximum number of results to return. Defaults to 40. Max 80 accounts.

    offset

    Skip the first n results.

    Return Value

    Search results.

  • Retrieve lists in which the given account id is present

    Declaration

    Swift

    public func getListsContainingAccount(id: String) async throws -> [List]
  • Return all conversations.

    Direct conversations with other participants. (Currently, just threads containing a post with “direct” visibility.)

    Declaration

    Swift

    func getConversations(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Conversation]>
  • Removes a conversation from your list of conversations.

    Declaration

    Swift

    func deleteConversation(id: String) async throws
  • Removes a conversation from your list of conversations.

    Declaration

    Swift

    func setConversationAsRead(id: String) async throws -> Conversation
  • adminGetDomainBlocks() Asynchronous

    Show information about all blocked domains.

    Declaration

    Swift

    func adminGetDomainBlocks() async throws -> [DomainBlock]

    Return Value

    array of blocked domains

  • Show information about a single blocked domain.

    Declaration

    Swift

    func adminGetDomainBlock(id: String) async throws -> DomainBlock?

    Parameters

    id

    The ID of the DomainBlock in the instance’s database

    Return Value

    DomainBlock (optional)

  • Blocks a domain on the current instance.

    • hide all public posts from it
    • hide all notifications from it
    • remove all followers from it
    • prevent following new users from it (but does not remove existing follows)

    Note that the call will be successful even if the domain is already blocked, or if the domain does not exist, or if the domain is not a domain.

    Declaration

    Swift

    func adminBlockDomain(params: BlockDomainParams) async throws -> DomainBlock
  • Lift a block against a domain. Note that the call will be successful even if the domain was not previously blocked.

    Declaration

    Swift

    func adminUnblockDomain(domain: String) async throws

    Parameters

    domain

    The ID of the DomainAllow in the database.

  • View domains the user has blocked.

    Declaration

    Swift

    func userGetDomainBlocks(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[String]>

    Parameters

    pageInfo

    PagedInfo object for max/min/since ids

    limit

    Maximum number of results to return. Defaults to 40.

    Return Value

    Paginated response with an array of sttrings

  • Blocks a domain on the current instance.

    • hide all public posts from it
    • hide all notifications from it
    • remove all followers from it
    • prevent following new users from it (but does not remove existing follows)

    Note that the call will be successful even if the domain is already blocked, or if the domain does not exist, or if the domain is not a domain.

    Declaration

    Swift

    func userBlockDomain(domain: String) async throws

    Parameters

    domain

    the domain to block (e.g “somewhere.social”)

  • Remove a domain block, if it exists in the user’s array of blocked domains. Note that the call will be successful even if the domain was not previously blocked.

    Declaration

    Swift

    func userUnblockDomain(domain: String) async throws

    Parameters

    domain

    the instance’s id of the domain being unblocked

  • Get tags featured by user.

    Note

    Requires featured tags feature to be available.

    Declaration

    Swift

    func getFeaturedTags(forUser userID: String) async throws -> [FeaturedTag]

    Parameters

    userID

    ID of user in database.

    Return Value

    The featured tags or an error if unable to retrieve.

  • getFeaturedTags() Asynchronous

    List all hashtags featured on your profile.

    Note

    Requires featured tags feature to be available.

    Declaration

    Swift

    func getFeaturedTags() async throws -> [FeaturedTag]

    Return Value

    The featured tags or an error if unable to retrieve.

  • Shows up to 10 recently-used tags.

    Note

    Requires featured tags feature to be available.

    Declaration

    Swift

    func getFeaturedTagsSuggestions() async throws -> [Tag]

    Return Value

    Array of Tag.

  • featureTag(name:) Asynchronous

    Promote a hashtag on your profile.

    Note

    Requires featured tags feature to be available.

    Declaration

    Swift

    @discardableResult
    func featureTag(name: String) async throws -> FeaturedTag

    Parameters

    name

    The hashtag to be featured, without the hash sign.

  • unfeatureTag(id:) Asynchronous

    Stop promoting a hashtag on your profile.

    Note

    Requires featured tags feature to be available.

    Declaration

    Swift

    func unfeatureTag(id: String) async throws

    Parameters

    id

    The ID of the FeaturedTag in the database.

  • getFilters() Asynchronous

    Obtain a list of all filter groups for the current user.

    Declaration

    Swift

    func getFilters() async throws -> [Filter]

    Return Value

    The filters or an error if unable to retrieve.

  • getFilter(id:) Asynchronous

    Obtain a single filter group owned by the current user.

    Declaration

    Swift

    func getFilter(id: String) async throws -> Filter

    Parameters

    id

    The ID of the Filter in the database.

    Return Value

    the Filter, if successful, throws an error if not

  • deleteFilter(id:) Asynchronous

    Delete a filter /// - Parameters: - id: The ID of the Filter in the database.

    Declaration

    Swift

    func deleteFilter(id: String) async throws
  • getInstanceInfo() Asynchronous

    Obtain general information about the server

    Declaration

    Swift

    public func getInstanceInfo() async throws -> Instance
  • getLists() Asynchronous

    Fetch all lists that the user owns.

    Declaration

    Swift

    func getLists() async throws -> [List]
  • getList(id:) Asynchronous

    Fetch the list with the given ID. Used for verifying the title of a list, and which replies to show within that list.

    Declaration

    Swift

    func getList(id: String) async throws -> List

    Parameters

    id

    The ID of the List in the database.

    Return Value

    the List, if successful, throws an error if not

  • createList(params:) Asynchronous

    Create a new list.

    Declaration

    Swift

    func createList(params: ListParams) async throws -> List

    Return Value

    the List created, if successful, throws an error if not

  • createList(id:params:) Asynchronous

    Change the title of a list, or which replies to show.

    Declaration

    Swift

    func createList(id: String, params: ListParams) async throws -> List

    Return Value

    the List created, if successful, throws an error if not

  • deleteList(id:) Asynchronous

    Delete a list

    Declaration

    Swift

    func deleteList(id: String) async throws
  • View accounts in a list

    Declaration

    Swift

    func getListAccounts(id: String, _ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]>

    Return Value

    a PagedResult with an array of accounts if successful, throws an error if not

  • Add accounts to a list

    Declaration

    Swift

    func addAccountsToList(id: String, params: AddAccountsToListParams) async throws
  • Remove account from a list

    Declaration

    Swift

    func removeAccountsFromList(id: String, params: RemoveAccountsFromListParams) async throws
  • Uploads a media to the server so it can be used when publishing posts

    Declaration

    Swift

    func uploadMedia(_ params: UploadMediaAttachmentParams, mimeType: String) async throws -> UploadedMediaAttachment
  • getMedia(id:) Asynchronous

    Retrieve the details of a media attachment that corresponds to the given identifier.

    Requests to Mastodon API flavour return nil until the attachment has finished processing.

    Declaration

    Swift

    func getMedia(id: String) async throws -> MediaAttachment?

    Parameters

    id

    The local ID of the attachment.

    Return Value

    Attachment with a url to the media if available. nil otherwise.

  • updateMedia(id:_:) Asynchronous

    Update media parameters, before it is posted.

    Declaration

    Swift

    @discardableResult
    func updateMedia(id: String, _ params: UpdateMediaAttachmentParams) async throws -> MediaAttachment

    Parameters

    id

    the ID of the media attachment to be changed.

    params

    the updated content of the media.

    Return Value

    the media after the update.

  • Get all notifications concerning the user

    Declaration

    Swift

    func getNotifications(params: TootNotificationParams = .init(), _ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[TootNotification]>

    Parameters

    limit

    Maximum number of results to return. Defaults to 15 notifications. Max 30 notifications.

  • getNotification(id:) Asynchronous

    Get info about a single notification

    Declaration

    Swift

    func getNotification(id: String) async throws -> TootNotification
  • Clear all notifications from the server.

    Declaration

    Swift

    func dismissAllNotifications() async throws
  • Dismiss a single notification from the server.

    Declaration

    Swift

    func dismissNotification(id: String) async throws
  • Add a Web Push API subscription to receive notifications. Each access token can have one push subscription.

    If you create a new subscription, the old subscription is deleted.

    Declaration

    Swift

    @discardableResult
    func createPushSubscription(params: PushSubscriptionParams) async throws -> PushSubscription
  • getPushSubscription() Asynchronous

    View the PushSubscription currently associated with this access token.

    Declaration

    Swift

    func getPushSubscription() async throws -> PushSubscription
  • Updates the current push subscription. Only the data part can be updated.

    To change fundamentals, a new subscription must be created instead.

    Declaration

    Swift

    func changePushSubscription(params: PushSubscriptionUpdateParams) async throws -> PushSubscription
  • Retrieve a list of OAuth applications

    • This method requires the admin:write scope.
    • This method requires the pleroma API flavour.

    Declaration

    Swift

    func adminGetOauthApps(_ page: Int = 1, params: ListOauthAppsParams? = nil) async throws -> [PleromaOauthApp]?
  • Delete OAuth application

    • This method requires the admin:write scope.
    • This method requires the pleroma API flavour.

    Declaration

    Swift

    func adminDeleteOauthApp(appId: Int) async throws
  • getPoll(id:) Asynchronous

    Obtain a poll with the specified id.

    Declaration

    Swift

    func getPoll(id: Poll.ID) async throws -> Poll
  • votePoll(id:choices:) Asynchronous

    Vote on a poll.

    Declaration

    Swift

    @discardableResult
    func votePoll(id: Poll.ID, choices: IndexSet) async throws -> Poll

    Parameters

    id

    The ID of the Poll.

    choices

    Set of indices representing votes for each option (starting from 0).

    Return Value

    The Poll that was voted on.

  • publishPost(_:) Asynchronous

    Publishes the post based on the components provided

    Declaration

    Swift

    func publishPost(_ params: PostParams) async throws -> Post

    Parameters

    PostParams

    post components to be published

    Return Value

    the published post, if successful, throws an error if not

  • editPost(id:_:) Asynchronous

    Edit a given post to change its text, sensitivity, media attachments, or poll. Note that editing a poll’s options will reset the votes.

    Declaration

    Swift

    func editPost(id: String, _ params: EditPostParams) async throws -> Post

    Parameters

    id

    the ID of the psot to be changed

    params

    the updated content of the post to be posted

    Return Value

    the post after the update

  • getPost(id:) Asynchronous

    Gets a single post

    Declaration

    Swift

    func getPost(id: String) async throws -> Post

    Parameters

    id

    the ID of the post to be retrieved

    Return Value

    the post retrieved, if successful, throws an error if not

  • getContext(id:) Asynchronous

    View statuses above and below this post in the thread.

    Public for public posts limited to 40 ancestors and 60 descendants with a maximum depth of 20. User token + read:statuses for up to 4,096 ancestors, 4,096 descendants, unlimited depth, and private posts.

    Declaration

    Swift

    func getContext(id: String) async throws -> Context
  • deletePost(id:) Asynchronous

    Deletes a single post

    Declaration

    Swift

    func deletePost(id: String) async throws -> Post

    Parameters

    id

    the ID of the post to be deleted

    Return Value

    the post deleted (for delete and redraft), if successful, throws an error if not

  • favouritePost(id:) Asynchronous

    Undocumented

    Declaration

    Swift

    func favouritePost(id: String) async throws -> Post
  • unfavouritePost(id:) Asynchronous

    Undocumented

    Declaration

    Swift

    func unfavouritePost(id: String) async throws -> Post
  • boostPost(id:) Asynchronous

    Reshare a post on your own profile.

    Declaration

    Swift

    func boostPost(id: String) async throws -> Post
  • unboostPost(id:) Asynchronous

    Undo a reshare of a post.

    Declaration

    Swift

    func unboostPost(id: String) async throws -> Post
  • bookmarkPost(id:) Asynchronous

    Privately bookmark a post.

    Declaration

    Swift

    func bookmarkPost(id: String) async throws -> Post
  • unbookmarkPost(id:) Asynchronous

    Remove a post from your private bookmarks.

    Declaration

    Swift

    func unbookmarkPost(id: String) async throws -> Post
  • mutePost(id:) Asynchronous

    Do not receive notifications for the thread that this post is part of. Must be a thread in which you are a participant.

    Declaration

    Swift

    func mutePost(id: String) async throws -> Post
  • unmutePost(id:) Asynchronous

    Start receiving notifications again for the thread that this post is part of.

    Declaration

    Swift

    func unmutePost(id: String) async throws -> Post
  • pinPost(id:) Asynchronous

    Feature one of your own public posts at the top of your profile.

    Declaration

    Swift

    func pinPost(id: String) async throws -> Post
  • unpinPost(id:) Asynchronous

    Unfeature a post from the top of your profile.

    Declaration

    Swift

    func unpinPost(id: String) async throws -> Post
  • View who boosted a given post.

    Declaration

    Swift

    func getAccountsBoosted(id: String) async throws -> [Account]
  • View who favourited a given post.

    Declaration

    Swift

    func getAccountsFavourited(id: String) async throws -> [Account]
  • getHistory(id:) Asynchronous

    Get all known versions of a post, including the initial and current states.

    Declaration

    Swift

    func getHistory(id: String) async throws -> [PostEdit]
  • getPostSource(id:) Asynchronous

    Obtain the source properties for a post so that it can be edited.

    Declaration

    Swift

    func getPostSource(id: String) async throws -> PostSource
  • List accounts visible in the directory.

    Declaration

    Swift

    func getProfileDirectory(params: ProfileDirectoryParams, offset: Int? = nil, limit: Int? = nil) async throws -> [Account]

    Parameters

    limit

    How many accounts to load. Defaults to 40 accounts. Max 80 accounts.

    params

    Includes order and local parameters.

    Return Value

    Array of Account.

  • Follow the given account. Can also be used to update whether to show reposts or enable notifications.

    Declaration

    Swift

    public func followAccount(by id: String, params: FollowAccountParams? = nil) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • followAccountURI(by:) Asynchronous

    Follow the given account; can be be the account name on the instance you’re on, or the user’s URI

    Declaration

    Swift

    public func followAccountURI(by uri: String) async throws -> Relationship

    Parameters

    uri

    account name on the instance you’re on or a users URI (e.g @test@instance.test)

    Return Value

    your relationship with that account after following

  • lookupAccount(uri:) Asynchronous

    Looks up an account based on it’s account name or URI, and returns a payload that contains the instance’s account id

    Declaration

    Swift

    public func lookupAccount(uri: String) async throws -> Account

    Parameters

    uri

    account name on the instance you’re on or a users URI (e.g test@instance.test)

    Return Value

    the looked up account, or an error if unable to retrieve

  • unfollowAccount(by:) Asynchronous

    Unfollow the given account.

    Declaration

    Swift

    public func unfollowAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • Remove the given account from your followers.

    Declaration

    Swift

    public func removeAccountFromFollowers(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • blockAccount(by:) Asynchronous

    Block the given account. Clients should filter posts from this account if received (e.g. due to a boost in the Home timeline)

    Declaration

    Swift

    public func blockAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • unblockAccount(by:) Asynchronous

    Unblock the given account

    Declaration

    Swift

    public func unblockAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • Get all accounts which the current account is blocking

    Declaration

    Swift

    public func getBlockedAccounts(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]>

    Parameters

    pageInfo

    PagedInfo object for max/min/since

    limit

    Maximum number of results to return. Defaults to 40 accounts. Max 80 accounts.

    Return Value

    the accounts requested

  • Mute the given account. Clients should filter posts and notifications from this account, if received (e.g. due to a boost in the Home timeline).

    Declaration

    Swift

    public func muteAccount(by id: String, params: MuteAccountParams? = nil) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • unmuteAccount(by:) Asynchronous

    Unmute the given account.

    Declaration

    Swift

    public func unmuteAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • Get all accounts which the current account is blocking

    Declaration

    Swift

    public func getMutedAccounts(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]>

    Parameters

    pageInfo

    PagedInfo object for max/min/since

    limit

    Maximum number of results to return. Defaults to 40 accounts. Max 80 accounts.

    Return Value

    the accounts requested

  • pinAccount(by:) Asynchronous

    Add the given account to the user’s featured profiles. (Featured profiles are currently shown on the user’s own public profile.)

    Declaration

    Swift

    public func pinAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • unpinAccount(by:) Asynchronous

    Remove the given account from the user’s featured profiles.

    Declaration

    Swift

    public func unpinAccount(by id: String) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • Accounts that the user is currently featuring on their profile.

    Declaration

    Swift

    public func getEndorsements(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Account]>

    Parameters

    pageInfo

    PagedInfo object for max/min/since

    limit

    Maximum number of results to return. Defaults to 40 accounts. Max 80 accounts.

    Return Value

    the accounts requested

  • Sets a private note on a user.

    Declaration

    Swift

    public func setNoteForAccount(by id: String, params: SetNoteForAccountParams? = nil) async throws -> Relationship

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested (including the note), or an error if unable to retrieve

  • getRelationships(by:) Asynchronous

    Find out whether a given account is followed, blocked, muted, etc.

    Declaration

    Swift

    public func getRelationships(by ids: [String]) async throws -> [Relationship]

    Parameters

    id

    the ID of the Account in the instance database.

    Return Value

    the relationship to the account requested, or an error if unable to retrieve

  • Obtain a list of all accounts that follow a given account, filtered for accounts you follow.

    Declaration

    Swift

    public func getFamiliarFollowers(by ids: [String]) async throws -> [FamiliarFollowers]

    Parameters

    ids

    Find familiar followers for the provided account IDs.

    Return Value

    array of FamiliarFollowers

  • schedulePost(_:) Asynchronous

    Schedules a post based on the components provided

    Declaration

    Swift

    func schedulePost(_ params: ScheduledPostParams) async throws -> ScheduledPost

    Parameters

    ScheduledPostParams

    post components to be published

    Return Value

    the ScheduledPost, if successful, throws an error if not

  • Gets scheduled posts

    Declaration

    Swift

    func getScheduledPost(minId: String?, maxId: String?, sinceId: String?, limit: Int?) async throws -> [ScheduledPost]

    Parameters

    minId

    Return results immediately newer than ID.

    maxId

    Return results older than ID

    sinceId

    Return results newer than ID

    limit

    Maximum number of results to return. Defaults to 20. Max 40

    Return Value

    array of scheduled posts (empty if none), an error if any issue

  • Gets scheduled posts

    Declaration

    Swift

    func getScheduledPosts(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[ScheduledPost]>

    Return Value

    the scheduled posts requested, or an error if unable to retrieve

  • getScheduledPost(id:) Asynchronous

    Gets a single Scheduled post by id

    Declaration

    Swift

    func getScheduledPost(id: String) async throws -> ScheduledPost?

    Parameters

    id

    the ID of the post to be retrieved

    Return Value

    the scheduled post retrieved, if successful, throws an error if not

  • Edit a given post to change its text, sensitivity, media attachments, or poll. Note that editing a poll’s options will reset the votes.

    Declaration

    Swift

    func updateScheduledPostDate(id: String, _ params: ScheduledPostParams) async throws -> ScheduledPost?

    Parameters

    id

    the ID of the post to be changed

    params

    the updated content of the post to be posted

    Return Value

    the post after the update

  • Deletes a single scheduled post

    Declaration

    Swift

    func deleteScheduledPost(id: String) async throws

    Parameters

    id

    the ID of the post to be deleted

    Return Value

    the post deleted (for delete and redraft), if successful, throws an error if not

  • Search for content in accounts, posts and hashtags.

    Declaration

    Swift

    func search(params: SearchParams, _ pageInfo: PagedInfo? = nil, limit: Int? = nil, offset: Int? = nil) async throws -> Search

    Parameters

    params

    The search parameters.

    pageInfo

    PagedInfo object for max/min/since ids.

    limit

    Maximum number of results to return. Defaults to 40.

    offset

    Skip the first n results.

    Return Value

    Search results.

  • getSuggestions(limit:) Asynchronous

    Accounts that are promoted by staff, or that the user has had past positive interactions with, but is not yet following.

    Declaration

    Swift

    func getSuggestions(limit: Int? = nil) async throws -> [Suggestion]

    Parameters

    limit

    Maximum number of results to return. Defaults to 40, max 80.

    Return Value

    Array of Suggestion.

  • removeSuggestion(id:) Asynchronous

    Remove an account from follow suggestions.

    Declaration

    Swift

    func removeSuggestion(id: String) async throws

    Parameters

    id

    The ID of the Account in the database.

  • getTag(_:) Asynchronous

    Get a tag.

    Declaration

    Swift

    func getTag(_ id: String) async throws -> Tag

    Parameters

    id

    Name of the tag.

  • followTag(_:) Asynchronous

    Follow a tag.

    Note

    Requires hashtag following feature to be available.

    Declaration

    Swift

    @discardableResult
    func followTag(_ id: String) async throws -> Tag

    Parameters

    id

    Name of the tag.

  • unfollowTag(_:) Asynchronous

    Unfollow a tag.

    Note

    Requires hashtag following feature to be available.

    Declaration

    Swift

    @discardableResult
    func unfollowTag(_ id: String) async throws -> Tag

    Parameters

    id

    Name of the tag.

  • Get all tags which the current account is following.

    Note

    Requires hashtag following feature to be available.

    Declaration

    Swift

    func getFollowedTags(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Tag]>

    Parameters

    pageInfo

    PagedInfo object for max/min/since ids.

    limit

    Maximum number of results to return. Defaults to 100 tags. Max 200 tags.

    Return Value

    the tags requested

  • Retrieves a timeline

    Declaration

    Swift

    public func getTimeline(_ timeline: Timeline, pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Post]>

    Parameters

    timeline

    The timeline being requested

    pageInfo

    a PageInfo struct that tells the API how to page the response, typically with a minId set of the highest id you last saw

    limit

    Maximum number of results to return (defaults to 20 on Mastodon with a max of 40)

    Return Value

    a PagedResult containing the posts retrieved

  • Get trending tags

    Declaration

    Swift

    func getTrendingTags(limit: Int? = nil, offset: Int? = nil) async throws -> [Tag]

    Parameters

    limit

    Maximum number of results to return. Defaults to 10, max 20.

    offset

    Skip the first n results.

    Return Value

    Array of Tag.

  • Get trending posts

    Declaration

    Swift

    func getTrendingPosts(limit: Int? = nil, offset: Int? = nil) async throws -> [Post]

    Parameters

    limit

    Maximum number of results to return. Defaults to 20, max 40.

    offset

    Skip the first n results.

    Return Value

    Array of Post.

  • Get trending links

    Declaration

    Swift

    func getTrendingLinks(limit: Int? = nil, offset: Int? = nil) async throws -> [TrendingLink]

    Parameters

    limit

    Maximum number of results to return. Defaults to 10, max 20.

    offset

    Skip the first n results.

    Return Value

    Array of TrendingLink.

Encoding/Decoding and fetching data

  • Declaration

    Swift

    public static func == (lhs: TootClient, rhs: TootClient) -> Bool
  • Provides the URL for authorizing with the current instanceURL

    Declaration

    Swift

    public func createAuthorizeURL(callbackURI: String) async throws -> URL

    Return Value

    A URL which can be browsed to continue authorization

  • Provides the URL for authorizing, with a custom server URL.

    Declaration

    Swift

    public func createAuthorizeURL(server: URL, callbackURI: String) async throws -> URL

    Return Value

    A URL which can be browsed to continue authorization

  • Facility method to complete authentication by processing the response from the authorization step. Exchange the callback authorization code for an accessToken

    Declaration

    Swift

    public func collectToken(returnUrl: URL, callbackURI: String) async throws -> String

    Parameters

    returnUrl

    The full url including query parameters received by the service following the redirect after successfull authorizaiton

    callbackURI

    The callback URI (redirect_uri) which was used to initiate the authorization flow. Must match one of the redirect_uris declared during app registration.

  • Exchange the callback authorization code for an accessToken.

    Declaration

    Swift

    public func collectToken(code: String, clientId: String, clientSecret: String, callbackURI: String) async throws -> String

    Parameters

    code

    The authorization code returned by the server

    clientId

    The client id of the application

    clientSecret

    The client secret of the application

    callbackURI

    The callback URL (redirect_uri) which was used to initiate the authorization flow. Must match one of the redirect_uris declared during app registration.

  • Undocumented

    Declaration

    Swift

    public func collectRegistrationToken(clientId: String, clientSecret: String, callbackURI: String) async throws -> String
  • connect() Asynchronous

    Uses the currently available credentials to connect to an instance and detect the most compatible server flavour.

    Declaration

    Swift

    public func connect() async throws
  • Returns true if this instance of TootClient has no accessToken.

    Declaration

    Swift

    public var isAnonymous: Bool { get }
  • Returns true if this instance of TootClient can perform methods that are related to given feature.

    Declaration

    Swift

    public func supportsFeature(_ feature: TootFeature) -> Bool

    Parameters

    feature

    The feature to check if is supported.

    Return Value

    true if the feature is supported.