TootClient
public class TootClient : @unchecked Sendable
extension TootClient: Equatable
Undocumented
-
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
trueto see aprint()of outgoing requests.Declaration
Swift
public var debugRequests: Bool -
Set this to
trueto see aprint()of request response.Declaration
Swift
public var debugResponses: Bool -
Set this to
trueto see aprint()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
-
Initialize a new instance of
TootClientby 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
clientNameName of the client to be used in outgoing HTTP requests. Defaults to
TootSDKsessionthe URLSession being used internally, defaults to shared
instanceURLthe instance you are connecting to
accessTokenthe existing access token; if you already have one
scopesAn array of authentication scopes, defaults to
"read", "write", "follow", "push" -
init(connect:AsynchronousclientName: session: accessToken: scopes: ) 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 throwsParameters
instanceURLthe instance you are connecting to
clientNameName of the client to be used in outgoing HTTP requests. Defaults to
TootSDKsessionthe URLSession being used internally, defaults to shared
accessTokenthe existing access token; if you already have one
scopesAn 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() -
presentSignIn(callbackURI:AsynchronousprefersEphemeralWebBrowserSession: presentationContextProvider: ) 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 -> StringParameters
callbackURIThe callback URI (
redirect_uri) which was used to initiate the authorization flow. Must match one of the redirect_uris declared during app registration.prefersEphemeralWebBrowserSessionA Boolean value that indicates whether the session should ask the browser for a private authentication session.
presentationContextProviderA 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()AsynchronousA test to make sure that the user token works, and retrieves the account information
Declaration
Swift
public func verifyCredentials() async throws -> AccountReturn Value
Returns the current authenticated user’s account, or throws an error if unable to retrieve
-
updateCredentials(params:Asynchronous) Update the user’s display and preferences.
Declaration
Swift
public func updateCredentials(params: UpdateCredentialsParams) async throws -> AccountReturn 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 -> AccountParameters
idthe ID of the Account in the instance database.
Return Value
the account requested, or an error if unable to retrieve
-
getFollowers(for:Asynchronous_: limit: ) 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
-
getFollowing(for:Asynchronous_: limit: ) 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
idthe ID of the Account in the instance database.
pageInfoPagedInfo object for max/min/since
limitMaximum number of results to return. Defaults to 40 accounts. Max 80 accounts.
Return Value
the accounts requested, or an error if unable to retrieve
-
registerAccount(params:Asynchronous) 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 -
searchAccounts(params:Asynchronouslimit: offset: ) 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
paramsThe search parameters.
limitMaximum number of results to return. Defaults to 40. Max 80 accounts.
offsetSkip the first n results.
Return Value
Search results.
-
getListsContainingAccount(id:Asynchronous) Retrieve lists in which the given account
idis presentDeclaration
Swift
public func getListsContainingAccount(id: String) async throws -> [List] -
getConversations(_:Asynchronouslimit: ) 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]> -
deleteConversation(id:Asynchronous) Removes a conversation from your list of conversations.
Declaration
Swift
func deleteConversation(id: String) async throws -
setConversationAsRead(id:Asynchronous) Removes a conversation from your list of conversations.
Declaration
Swift
func setConversationAsRead(id: String) async throws -> Conversation -
adminGetDomainBlocks()AsynchronousShow information about all blocked domains.
Declaration
Swift
func adminGetDomainBlocks() async throws -> [DomainBlock]Return Value
array of blocked domains
-
adminGetDomainBlock(id:Asynchronous) Show information about a single blocked domain.
Declaration
Swift
func adminGetDomainBlock(id: String) async throws -> DomainBlock?Parameters
idThe ID of the DomainBlock in the instance’s database
Return Value
DomainBlock (optional)
-
adminBlockDomain(params:Asynchronous) 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 -
adminUnblockDomain(domain:Asynchronous) 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 throwsParameters
domainThe ID of the DomainAllow in the database.
-
userGetDomainBlocks(_:Asynchronouslimit: ) View domains the user has blocked.
Declaration
Swift
func userGetDomainBlocks(_ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[String]>Parameters
pageInfoPagedInfo object for max/min/since ids
limitMaximum number of results to return. Defaults to 40.
Return Value
Paginated response with an array of sttrings
-
userBlockDomain(domain:Asynchronous) 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 throwsParameters
domainthe domain to block (e.g “somewhere.social”)
-
userUnblockDomain(domain:Asynchronous) 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 throwsParameters
domainthe instance’s id of the domain being unblocked
-
getFeaturedTags(forUser:Asynchronous) Get tags featured by user.
Note
Requires featured tags feature to be available.Declaration
Swift
func getFeaturedTags(forUser userID: String) async throws -> [FeaturedTag]Parameters
userIDID of user in database.
Return Value
The featured tags or an error if unable to retrieve.
-
getFeaturedTags()AsynchronousList 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.
-
getFeaturedTagsSuggestions()Asynchronous -
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 -> FeaturedTagParameters
nameThe 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 throwsParameters
idThe ID of the FeaturedTag in the database.
-
getFilters()AsynchronousObtain 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 -> FilterParameters
idThe 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()AsynchronousObtain general information about the server
Declaration
Swift
public func getInstanceInfo() async throws -> Instance -
getLists()AsynchronousFetch 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 -> ListParameters
idThe 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 -> ListReturn Value
the List created, if successful, throws an error if not
-
createList(id:Asynchronousparams: ) Change the title of a list, or which replies to show.
Declaration
Swift
func createList(id: String, params: ListParams) async throws -> ListReturn 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 -
getListAccounts(id:Asynchronous_: limit: ) 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
-
addAccountsToList(id:Asynchronousparams: ) Add accounts to a list
Declaration
Swift
func addAccountsToList(id: String, params: AddAccountsToListParams) async throws -
removeAccountsFromList(id:Asynchronousparams: ) Remove account from a list
Declaration
Swift
func removeAccountsFromList(id: String, params: RemoveAccountsFromListParams) async throws -
uploadMedia(_:AsynchronousmimeType: ) 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
niluntil the attachment has finished processing.Declaration
Swift
func getMedia(id: String) async throws -> MediaAttachment?Parameters
idThe local ID of the attachment.
Return Value
Attachmentwith aurlto the media if available.nilotherwise. -
updateMedia(id:Asynchronous_: ) Update media parameters, before it is posted.
Declaration
Swift
@discardableResult func updateMedia(id: String, _ params: UpdateMediaAttachmentParams) async throws -> MediaAttachmentParameters
idthe ID of the media attachment to be changed.
paramsthe updated content of the media.
Return Value
the media after the update.
-
getNotifications(params:Asynchronous_: limit: ) Get all notifications concerning the user
Declaration
Swift
func getNotifications(params: TootNotificationParams = .init(), _ pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[TootNotification]>Parameters
limitMaximum 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 -
dismissAllNotifications()AsynchronousClear all notifications from the server.
Declaration
Swift
func dismissAllNotifications() async throws -
dismissNotification(id:Asynchronous) Dismiss a single notification from the server.
Declaration
Swift
func dismissNotification(id: String) async throws -
createPushSubscription(params:Asynchronous) 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()AsynchronousView the PushSubscription currently associated with this access token.
Declaration
Swift
func getPushSubscription() async throws -> PushSubscription -
changePushSubscription(params:Asynchronous) 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 -
adminGetOauthApps(_:Asynchronousparams: ) Retrieve a list of OAuth applications
- This method requires the
admin:writescope. - This method requires the pleroma API flavour.
Declaration
Swift
func adminGetOauthApps(_ page: Int = 1, params: ListOauthAppsParams? = nil) async throws -> [PleromaOauthApp]? - This method requires the
-
adminDeleteOauthApp(appId:Asynchronous) Delete OAuth application
- This method requires the
admin:writescope. - This method requires the pleroma API flavour.
Declaration
Swift
func adminDeleteOauthApp(appId: Int) async throws - This method requires the
-
getPoll(id:Asynchronous) -
votePoll(id:Asynchronouschoices: ) -
publishPost(_:Asynchronous) Publishes the post based on the components provided
Declaration
Swift
func publishPost(_ params: PostParams) async throws -> PostParameters
PostParamspost 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 -> PostParameters
idthe ID of the psot to be changed
paramsthe 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 -> PostParameters
idthe 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 -> PostParameters
idthe 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 -
getAccountsBoosted(id:Asynchronous) View who boosted a given post.
Declaration
Swift
func getAccountsBoosted(id: String) async throws -> [Account] -
getAccountsFavourited(id:Asynchronous) 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 -
getProfileDirectory(params:Asynchronousoffset: limit: ) List accounts visible in the directory.
Declaration
Swift
func getProfileDirectory(params: ProfileDirectoryParams, offset: Int? = nil, limit: Int? = nil) async throws -> [Account]Parameters
limitHow many accounts to load. Defaults to 40 accounts. Max 80 accounts.
paramsIncludes order and local parameters.
Return Value
Array of
Account. -
followAccount(by:Asynchronousparams: ) 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 -> RelationshipParameters
idthe 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 -> RelationshipParameters
uriaccount 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 -> AccountParameters
uriaccount 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 -> RelationshipParameters
idthe ID of the Account in the instance database.
Return Value
the relationship to the account requested, or an error if unable to retrieve
-
removeAccountFromFollowers(by:Asynchronous) Remove the given account from your followers.
Declaration
Swift
public func removeAccountFromFollowers(by id: String) async throws -> RelationshipParameters
idthe 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 -> RelationshipParameters
idthe 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 -> RelationshipParameters
idthe ID of the Account in the instance database.
Return Value
the relationship to the account requested, or an error if unable to retrieve
-
getBlockedAccounts(_:Asynchronouslimit: ) 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
pageInfoPagedInfo object for max/min/since
limitMaximum number of results to return. Defaults to 40 accounts. Max 80 accounts.
Return Value
the accounts requested
-
muteAccount(by:Asynchronousparams: ) 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 -> RelationshipParameters
idthe 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 -> RelationshipParameters
idthe ID of the Account in the instance database.
Return Value
the relationship to the account requested, or an error if unable to retrieve
-
getMutedAccounts(_:Asynchronouslimit: ) 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
pageInfoPagedInfo object for max/min/since
limitMaximum 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 -> RelationshipParameters
idthe 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 -> RelationshipParameters
idthe ID of the Account in the instance database.
Return Value
the relationship to the account requested, or an error if unable to retrieve
-
getEndorsements(_:Asynchronouslimit: ) 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
pageInfoPagedInfo object for max/min/since
limitMaximum number of results to return. Defaults to 40 accounts. Max 80 accounts.
Return Value
the accounts requested
-
setNoteForAccount(by:Asynchronousparams: ) Sets a private note on a user.
Declaration
Swift
public func setNoteForAccount(by id: String, params: SetNoteForAccountParams? = nil) async throws -> RelationshipParameters
idthe 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
idthe ID of the Account in the instance database.
Return Value
the relationship to the account requested, or an error if unable to retrieve
-
getFamiliarFollowers(by:Asynchronous) 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
idsFind 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 -> ScheduledPostParameters
ScheduledPostParamspost components to be published
Return Value
the ScheduledPost, if successful, throws an error if not
-
getScheduledPost(minId:AsynchronousmaxId: sinceId: limit: ) Gets scheduled posts
Declaration
Swift
func getScheduledPost(minId: String?, maxId: String?, sinceId: String?, limit: Int?) async throws -> [ScheduledPost]Parameters
minIdReturn results immediately newer than ID.
maxIdReturn results older than ID
sinceIdReturn results newer than ID
limitMaximum number of results to return. Defaults to 20. Max 40
Return Value
array of scheduled posts (empty if none), an error if any issue
-
getScheduledPosts(_:Asynchronouslimit: ) 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
idthe ID of the post to be retrieved
Return Value
the scheduled post retrieved, if successful, throws an error if not
-
updateScheduledPostDate(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 updateScheduledPostDate(id: String, _ params: ScheduledPostParams) async throws -> ScheduledPost?Parameters
idthe ID of the post to be changed
paramsthe updated content of the post to be posted
Return Value
the post after the update
-
deleteScheduledPost(id:Asynchronous) Deletes a single scheduled post
Declaration
Swift
func deleteScheduledPost(id: String) async throwsParameters
idthe ID of the post to be deleted
Return Value
the post deleted (for delete and redraft), if successful, throws an error if not
-
search(params:Asynchronous_: limit: offset: ) 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 -> SearchParameters
paramsThe search parameters.
pageInfoPagedInfo object for max/min/since ids.
limitMaximum number of results to return. Defaults to 40.
offsetSkip 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
limitMaximum 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 throwsParameters
idThe ID of the Account in the database.
-
getTag(_:Asynchronous) Get a tag.
Declaration
Swift
func getTag(_ id: String) async throws -> TagParameters
idName 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 -> TagParameters
idName 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 -> TagParameters
idName of the tag.
-
getFollowedTags(_:Asynchronouslimit: ) 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
pageInfoPagedInfo object for max/min/since ids.
limitMaximum number of results to return. Defaults to 100 tags. Max 200 tags.
Return Value
the tags requested
-
getTimeline(_:AsynchronouspageInfo: limit: ) Retrieves a timeline
Declaration
Swift
public func getTimeline(_ timeline: Timeline, pageInfo: PagedInfo? = nil, limit: Int? = nil) async throws -> PagedResult<[Post]>Parameters
timelineThe timeline being requested
pageInfoa PageInfo struct that tells the API how to page the response, typically with a minId set of the highest id you last saw
limitMaximum number of results to return (defaults to 20 on Mastodon with a max of 40)
Return Value
a PagedResult containing the posts retrieved
-
getTrendingTags(limit:Asynchronousoffset: ) -
getTrendingPosts(limit:Asynchronousoffset: ) -
getTrendingLinks(limit:Asynchronousoffset: ) Get trending links
Declaration
Swift
func getTrendingLinks(limit: Int? = nil, offset: Int? = nil) async throws -> [TrendingLink]Parameters
limitMaximum number of results to return. Defaults to 10, max 20.
offsetSkip the first n results.
Return Value
Array of
TrendingLink.
-
Declaration
Swift
public static func == (lhs: TootClient, rhs: TootClient) -> Bool -
createAuthorizeURL(callbackURI:Asynchronous) Provides the URL for authorizing with the current instanceURL
Declaration
Swift
public func createAuthorizeURL(callbackURI: String) async throws -> URLReturn Value
A URL which can be browsed to continue authorization
-
createAuthorizeURL(server:AsynchronouscallbackURI: ) Provides the URL for authorizing, with a custom server URL.
Declaration
Swift
public func createAuthorizeURL(server: URL, callbackURI: String) async throws -> URLReturn Value
A URL which can be browsed to continue authorization
-
collectToken(returnUrl:AsynchronouscallbackURI: ) 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 -> StringParameters
returnUrlThe full url including query parameters received by the service following the redirect after successfull authorizaiton
callbackURIThe 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 -> StringParameters
codeThe authorization code returned by the server
clientIdThe client id of the application
clientSecretThe client secret of the application
callbackURIThe 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()AsynchronousUses the currently available credentials to connect to an instance and detect the most compatible server flavour.
Declaration
Swift
public func connect() async throws -
Returns
trueif this instance ofTootClienthas noaccessToken.Declaration
Swift
public var isAnonymous: Bool { get } -
Returns
trueif this instance ofTootClientcan perform methods that are related to givenfeature.Declaration
Swift
public func supportsFeature(_ feature: TootFeature) -> BoolParameters
featureThe feature to check if is supported.
Return Value
trueif the feature is supported.
TootClient Class Reference