gotodonr

package module
v0.0.0-...-99acd51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2019 License: GPL-3.0 Imports: 18 Imported by: 1

README

Gotodon - REST

Gotodon REST is the foundation of Gotodon. It implements all REST calls on which other parts of Gotodon build upon. Since these calls can be very repetitive (i.e. the first two arguments are almost always baseUrl and accessToken) and everything (loading, storing, ...) has to be done by you, you can use Gotodon - Managed instead.

All repositories which Gotodon consists of:

Features

  • OAuth
    • Authorization Code Flow
    • Password Grant Flow
    • Client Credentials Flow
    • Verifying Application/Access Tokens
    • Revoking Access Tokens
  • All API endpoints as of July 2019

Getting Started

This section will cover everything necessary to get started, from registering a client to getting an access token using any of the three available flows (Authorization Code Flow, Password Grant Flow and Client Credentials Flow)

We start off by declaring constants and globals which will be frequently used in api calls.

const (
    // The address which points to the mastodon instance you want to access
    baseUrl = "domain.tld"
)

// The app, which holds the data used to identify the app, authorize it or receive push notifications.
// It contains the clientId, which identifies your client and is used for any token functions
// and the clientSecret, which is used to make sure it really is your client
// (typically used to create signatures of requests)
var app App

// The token which holds your accessToken, which is used to send authenticated requests. It is linked to
// both the app (through the clientId) and the account which authorized it.
// Warning: There is also a type of accessToken which is not linked to an account,
// which is used when using the Client Credentials Flow (where a client creates its own
// account instead of using an existing one). These tokens can't use account-based
// functions, like posting statuses and such (but can be used to get a regular accessToken).
var token Token

Registering the client

First we need to register this client as an app.

err, app = RegisterApp(
    // The baseUrl, as stated above, is the address of the server to connect to
    baseUrl,

    // The clientName is displayed on statuses on the bottom right (when the status is opened)
    "Gotodon",

    // If a website is set, a user can click on the clientName in a status and it will take him to it.
    "https://gitlab.com/Cyphrags/gotodon-examples/blob/master/rest_example.go",

    // The scopes set here are the "request boundaries", i.e. they are not yet granted but can limit
    // which scopes can be requested when authorizing the client.
    Scopes(ScopeRead, ScopeWrite, ScopeFollow, ScopePush),

    // Here you can set optional redirect uris, which again only limit which redirect uris can be set when
    // authorizing the client. You can leave this empty (even without the empty string) to use the default
    // "no redirect" (urn:ietf:wg:oauth:2.0:oob).
    "")

Authorizing the client

Now that we have registered the app, we need to authorize it. This will grant us an Access Token which will tells the server who is calling and which account the call will effect (i.e. who is posting the status or which profile to update with this nice, new avatar image).

There are three ways to authorize your client:

  1. Authorization Code Flow (ACF)
  2. Password Grant Flow (PGF)
  3. Client Credentials Flow (CCF)

ACF and PGF require that an account already exists. Additionally, ACF requires the user to confirm the app (which removes the to pass any password around which makes it ultimately safer). CCF will create a new account.

These might not be official/commonly used abbreviations. I used them here for simplicities sake.

Scopes

All authorization methods require a set of scopes which will restrict which functions the client can call. You can find a list of scopes in gotodonr/constants.go (and other constants too, like Visibility for statuses).

You should only request the scopes you really need rather than requesting everything. Doing so can reduce the damage caused if an access token is leaked or stolen.

Authorization Code Flow

In the Authorization Code Flow we first generate an URL which the user has to open (this website is the OAuth web endpoint of the mastodon server). The user then needs to confirm that he wants to authorize the app which will present him with an authorization code (using the redirect uri and a local webserver, the authorization code can also be retrieved automatically after the user hit confirm, instead of having them enter it somewhere).

authorizeUrl := GetAuthorizeUrl(
    baseUrl,
    app.ClientId,

    // This is where we actually request the scope for the client. These scopes are limited by the
    // scopes that were set when registering the client and can't exceed them (i.e. it is possible to request
    // ScopeReadAccounts here when you set ScopeRead when registering the client, but not vice versa)
    Scopes(ScopeRead, ScopeWrite, ScopeFollow, ScopePush),

    // The redirect uri can be used to redirect the authorization code to a different address, like a local
    // http server which could automatically read it out instead of having the user enter it.
    "")

// This placeholder variable needs to be filled with the authorization code and how that happens is up to you.
var authorizationCode string

After the user confirmed the authorization request and the authorization code was entered/retrieved, we simply exchange it for an access token (note that the scope used in GetAuthorizeUrl() and here need to be the same):

err, token = GetAccessTokenFromAuthorizationCode(
    baseUrl,
    app.ClientId,
    app.ClientSecret,
    authorizationCode,

    // These scopes need to match the scopes used in GetAuthorizeUrl(...)
    Scopes(ScopeRead, ScopeWrite, ScopeFollow, ScopePush),

    // The redirect uri can be used to redirect the accessToken to a different website (or to a local server
    // again) if you want to handle things differently. Leaving it empty will output the accessToken directly
    // and our variable t will hold onto it.
    "")
Password Grant Flow

In the Password Grant Flow we use a login-style flow to get an access token, which means that we simply send the username and password to the server to get an access token.

Requiring a user to login is a potential security risk and/or might scare off some users. In any case, the Authorization Code Flow is preferable (and I strongly advice you to use it).

err, token = GetAccessTokenFromLogin(
    baseUrl,
    app.ClientId,
    app.ClientSecret,

    // The username used to login (usually the e-mail address).
    // How you get the username is up to you (could be hardcoded, through environment variables or by
    // asking the user through a (web-)interface, popup, console, ...)
    username,

    // The password used to login.
    // How you get the password is up to you (could be hardcoded, through environment variables or by
    // asking the user through a (web-)interface, popup, console, ...)
    password,

    // This is where we actually request the scope for the client. These scopes are limited by the
    // scopes that were set when registering the client and can't exceed them (i.e. it is possible to request
    // ScopeReadAccounts here when you set ScopeRead when registering the client, but not vice versa)
    Scopes(ScopeRead, ScopeWrite, ScopeFollow, ScopePush),

    // The redirect uri can be used to redirect the accessToken to a different website (or to a local server
    // again) if you want to handle things differently. Leaving it empty will output the accessToken directly
    // and our variable t will hold onto it.
    "")
Client Credentials Flow

In the Client Credentials Flow we first get a special access token which we then use to create a new account and then get an actual access token for the account we created.

err, token = GetAccessTokenFromCredentials(
    baseUrl,
    app.ClientId,
    app.ClientSecret,

    // This is where we actually request the scope for the client. These scopes are limited by the
    // scopes that were set when registering the client and can't exceed them (i.e. it is possible to request
    // ScopeReadAccounts here when you set ScopeRead when registering the client, but not vice versa)
    Scopes(ScopeRead, ScopeWrite, ScopeFollow, ScopePush))

This token is not linked to an account and can't be used in any account related methods.

Now we use this token to create a new account.

err, token = CreateAccount(
    baseUrl,

    // The accessToken we got from GetAccessTokenFromCredentials()
    token.AccessToken,

    // The UserName which is used to "@" this account (@UserName@domain.tld)
    // This is not the displayName, which can always be changed.
    // The userName, however, can only be changed by moving the account.
    username,

    // The email address used for this account. It will receive the initial "confirm your account" email.
    email,

    // The password used to login (in case the client needs to login again or the user wants to login
    // through the web interface, app or another client).
    password,

    // Basically needs to be true and confirms that you agree with the terms and conditions.
    true,

    // The locale which affects the "confirm your account" email
    "en")

CreateAccount might throw an "you can't access this page" error if user registration is disabled on the server

Revoking an Access Token

If you ever need to revoke an access token (i.e. the client is deleted/uninstalled or gets a brand new token) you can simply use the function RevokeToken:

err = RevokeToken(baseUrl, app.ClientId, app.ClientSecret, token.AccessToken)

Verifying the client

Now that we have setup the client, we can finally do something with it. To test that everything went alright, we might simply post a status which will tell the world that everything is fine:

PostTextStatus(baseUrl, token.AccessToken, "MyClient is working!", "", false, "", VisibilityPublic, "en", "")

You can view the full example here: gotodon-examples/rest_example.go

Documentation

Index

Constants

View Source
const (
	ScopeWrite              string = "write"
	ScopeWriteAccounts      string = "write:accounts"
	ScopeWriteBlocks        string = "write:blocks"
	ScopeWriteConversations string = "write:conversations"
	ScopeWriteFavourites    string = "write:favourites"
	ScopeWriteFilters       string = "write:filters"
	ScopeWriteFollows       string = "write:follows"
	ScopeWriteLists         string = "write:lists"
	ScopeWriteMedia         string = "write:media"
	ScopeWriteMutes         string = "write:mutes"
	ScopeWriteNotifications string = "write:notifications"
	ScopeWriteReports       string = "write:reports"
	ScopeWriteStatuses      string = "write:statuses"
	ScopeRead               string = "read"
	ScopeReadAccounts       string = "read:accounts"
	ScopeReadBlocks         string = "read:blocks"
	ScopeReadFavourites     string = "read:favourites"
	ScopeReadFilters        string = "read:filters"
	ScopeReadFollows        string = "read:follows"
	ScopeReadLists          string = "read:lists"
	ScopeReadMutes          string = "read:mutes"
	ScopeReadNotifications  string = "read:notifications"
	ScopeReadSearch         string = "read:search"
	ScopeReadStatuses       string = "read:statuses"
	ScopeFollow             string = "follow"
	ScopePush               string = "push"
	ScopeAdminRead          string = "admin:read"
	ScopeAdminReadAccounts  string = "admin:read:accounts"
	ScopeAdminReadReports   string = "admin:read:reports"
	ScopeAdminWrite         string = "admin:write"
	ScopeAdminWriteAccounts string = "admin:write:accounts"
	ScopeAdminWriteReports  string = "admin:write:reports"

	VisibilityPublic   string = "public"   // Visibility used when posting a status
	VisibilityUnlisted string = "unlisted" // Visibility used when posting a status
	VisibilityPrivate  string = "private"  // Visibility used when posting a status
	VisibilityDirect   string = "direct"   // Visibility used when posting a status

	AttachmentUnknown string = "unknown" // Type of the attachment of a media post
	AttachmentImage   string = "image"   // Type of the attachment of a media post
	AttachmentGifv    string = "gifv"    // Type of the attachment of a media post
	AttachmentVideo   string = "video"   // Type of the attachment of a media post

	CardLink  string = "link"  // Type of status card
	CardPhoto string = "photo" // Type of status card
	CardVideo string = "video" // Type of status card
	CardRich  string = "rich"  // Type of status card

	ContextHome          string = "home"          // Context of a timeline
	ContextNotifications string = "notifications" // Context of a timeline
	ContextPublic        string = "public"        // Context of a timeline
	ContextThread        string = "thread"        // Context of a timeline

	DurationMinute     int = 60                  // Shortcut for a duration of a minute
	DurationHalfHour   int = 30 * DurationMinute // Shortcut for a duration of thirty minutes
	DurationHour       int = 60 * DurationMinute // Shortcut for a duration of an hour
	DurationQuarterDay int = 6 * DurationHour    // Shortcut for a duration of six hours
	DurationHalfDay    int = 12 * DurationHour   // Shortcut for a duration of twelve hours
	DurationDay        int = 24 * DurationHour   // Shortcut for a duration of twenty-four hours
	DurationWeek       int = 7 * DurationDay     // Shortcut for a duration of seven days

	NotificationFollow    string = "follow"    // Type of notifications to receive through the push service
	NotificationMention   string = "mention"   // Type of notifications to receive through the push service
	NotificationReblog    string = "reblog"    // Type of notifications to receive through the push service
	NotificationFavourite string = "favourite" // Type of notifications to receive through the push service
)

Variables

This section is empty.

Functions

func AddAccountsToList

func AddAccountsToList(baseUrl, accessToken, listId string, accounts ...string) error

Adds the accounts to the list

  listId: identifier of the list to be updated
accounts: slice of accounts which should be added to the list

func AuthorizeFollowRequest

func AuthorizeFollowRequest(baseUrl, accessToken, accountId string) error

Accepts a follower request

accountId: identifier of the account whose follow request should be accepted

func BlockDomain

func BlockDomain(baseUrl, accessToken, domain string) error

Blocks the given domain (strip any protocols and such, domain needs to be 'domain.tld')

domain: the domain to be blocked

func ClearNotifications

func ClearNotifications(baseUrl, accessToken string) error

Clear all notifications

func Contexts

func Contexts(context ...string) []string

Creates a slice of contexts

func DeleteFilter

func DeleteFilter(baseUrl, accessToken, filterId string) error

Removes a filter

filterId: identifier of the filter to be deleted

func DeleteFollowSuggestion

func DeleteFollowSuggestion(baseUrl, accessToken, accountId string) error

Deletes a follow suggestion

accountId: the account whose follow suggestion should be deleted

func DeleteList

func DeleteList(baseUrl, accessToken, listId string) error

Deletes the list

listId: identifier of the list to be updated

func DeleteScheduledStatus

func DeleteScheduledStatus(baseUrl, accessToken, scheduledId string) error

Deletes a scheduled status

scheduledId: identifier of the scheduled status to be updated

func DeleteStatus

func DeleteStatus(baseUrl, accessToken, statusId string) error

Deletes a status

statusId: identifier of the status to be deleted

func DeleteSubscription

func DeleteSubscription(baseUrl, accessToken string) error

Deletes the current subscription

func DismissNotification

func DismissNotification(baseUrl, accessToken, notificationId string) error

Dismisses a notification

notificationId: identifier of the notification to dismiss

Returns the notifications

func FocalPoint

func FocalPoint(x, y float64) string

Serializes a focal point

x: x-axis focal point, between 0.0 and 1.0
y: y-axis focal point, between 0.0 and 1.0

func GetAuthorizeUrl

func GetAuthorizeUrl(baseUrl, clientId, scope, redirectUri string) string

Construct an url used to get an authorization code which can be exchanged for an access token using GetAccessTokenFromAuthorizationCode.

      scope: space-separated list of scopes to be authorized for
redirectUri: uri the user will be redirected to, which will have the access token attached as url param (default: urn:ietf:wg:oauth:2.0:oob)

Returns the url the user needs to open in order to get an authorization code

func GetDomainBlocks

func GetDomainBlocks(baseUrl, accessToken string, limit int) (error, []string, string, string)

Get a page of domains the user has blocked

limit: max amount of results per page

Returns a page of domains the user has blocked and urls pointing to the previous and next page respectively

func GetUrl

func GetUrl(url, accessToken string, out interface{}) (error, http.Header, string, string, string)

Gets an url (used with the prev/next urls returned by functions with pagination)

	         url: the url to get
	accessToken: the access token to authenticate the request with (optional)
         out: struct which should be updated with received data (optional)

Returns any errors, headers, the answer body and two urls pointing to the previous and next page respectively

func RejectFollowRequest

func RejectFollowRequest(baseUrl, accessToken, accountId string) error

Rejects a follower request

accountId: identifier of the account whose follow request should be rejected

func RemoveAccountsFromList

func RemoveAccountsFromList(baseUrl, accessToken, listId string, accounts ...string) error

Removes the accounts from the list

  listId: identifier of the list to be updated
accounts: slice of accounts which should be removed from the list

func Report

func Report(baseUrl, accessToken, accountId string, statusIds []string, comment string, forward bool) error

Reports a user

accountId: identifier of the account to report
statusIds: statuses which show violations of the ToS (optional)
  comment: additional information on why the user is being reported (optional, up to 1000 characters)
  forward: forward the report to the accounts server if it isn't the local server (default: false)

func RevokeToken

func RevokeToken(baseUrl, clientId, clientSecret, accessToken string) error

Revokes an access token

func Scopes

func Scopes(permission ...string) string

Creates a comma-separated list of the selected scopes

func UnblockDomain

func UnblockDomain(baseUrl, accessToken, domain string) error

Unblocks the given domain (strip any protocols and such, domain needs to be 'domain.tld')

domain: the domain to be unblocked

Types

type Account

type Account struct {
	Id             string   `json:"id"`              // Local identifier of the account
	Username       string   `json:"username"`        // Username the person signed up with (used when @-ing: @Username)
	Account        string   `json:"acct"`            // Full account name (username@server.tld) or Username if the account belongs to the queried server
	DisplayName    string   `json:"display_name"`    // Display Name which can be edited by the user. If empty, use Username instead
	Locked         bool     `json:"locked"`          // Following a locked account will send a follow request (which has to be accepted) instead of directly following the account
	CreatedAt      string   `json:"created_at"`      // The timestamp at which the account was created
	FollowersCount int      `json:"followers_count"` // Amount of accounts following the account
	FollowingCount int      `json:"following_count"` // Amount of accounts the account follows
	StatusesCount  int      `json:"statuses_count"`  // Amount of statuses the account posted
	Url            string   `json:"url"`             // URL pointing to the profile of the account
	Avatar         string   `json:"avatar"`          // URL pointing to the image used as avatar by the account
	AvatarStatic   string   `json:"avatar_static"`   // URL pointing to the static image used as avatar by the account
	Header         string   `json:"header"`          // URL pointing to the image used as header by the account
	HeaderStatic   string   `json:"header_static"`   // URL pointing to the static image used as header by the account
	Source         Source   `json:"source"`          // Source data of the account
	Emojis         []Emoji  `json:"emojis"`          // Custom emojis from the account
	Moved          *Account `json:"moved"`           // A reference to the original account if the account was moved
	Bot            bool     `json:"bot"`             // True if the account is a bot
}

An account of a user, with profile data and statistics

func GetAccount

func GetAccount(baseUrl, accountId string) (error, Account)

Gets the Account associated with the AccountId.

Returns the account

func GetAccountBlocks

func GetAccountBlocks(baseUrl, accessToken string, limit int) (error, []Account, string, string)

Gets a page of accounts the user has blocked.

limit: maximum amount of results per page

Returns a page of accounts the user has blocked and uris pointing to the previous and next page.

func GetAssociatedAccount

func GetAssociatedAccount(baseUrl, accessToken string) (error, Account)

Gets the account associated with the given accessToken. (This is a helper function which is not part of the API)

func GetEndorsements

func GetEndorsements(baseUrl, accessToken string, limit int) (error, []Account, string, string)

Gets a page of accounts the user has endorsed (endorsed accounts are highlighted on the users profile)

limit: max amount of results per page

Returns a slice of endorsed accounts and two urls pointing to the next and previous page respectively

func GetFollowRequests

func GetFollowRequests(baseUrl, accessToken string, limit int) (error, []Account, string, string)

Returns a single page containing open follower requests

limit: maximum amount of accounts to retrieve (default: 40)

Returns a slice of accounts with a pending follow request and two urls pointing to the next and previous page respectively

func GetFollowSuggestions

func GetFollowSuggestions(baseUrl, accessToken string) (error, []Account)

Gets all follow suggestions

Returns a slice of suggested accounts

func GetFolloweds

func GetFolloweds(baseUrl, accessToken, accountId string, limit int) (error, []Account, string, string)

Gets a single page of accounts followed by the given account

accountId: id of the account the followeds should be retrieved from
    limit: maximum amount of accounts to retrieve (default: 40)

Returns a slice of Account followed and two urls pointing to the next and previous page respectively

Note that when accountId points to a local account, all followed accounts will be retrieved. If it points to a remote (federated) account, only local accounts will be retrieved.

func GetFollowers

func GetFollowers(baseUrl, accessToken, accountId string, limit int) (error, []Account, string, string)

Gets a single page of accounts following the given account

accountId: id of the account the followers should be retrieved from
    limit: maximum amount of accounts to retrieve (default: 40)

Returns a slice of accounts following and two urls pointing to the next and previous page respectively

Note that when accountId points to a local account, all followers will be retrieved. If it points to a remote (federated) account, only local accounts will be retrieved.

func GetMutes

func GetMutes(baseUrl, accessToken string, limit int) (error, []Account, string, string)

Gets a page of muted accounts

limit: max amount of results per page (default: 40)

Returns a slice of muted accounts and two urls pointing to the next and previous url respectively

func GetStatusFavouritedBy

func GetStatusFavouritedBy(baseUrl, statusId string, limit int) (error, []Account, string, string)

Gets a page of accounts which favourited a status

statusId: identifier of the status
   limit: max amount of results per page (default: 40)

Returns a slice of accounts which favourited the status and two urls pointing to the previous and next page respectively

func GetStatusRebloggedBy

func GetStatusRebloggedBy(baseUrl, statusId string, limit int) (error, []Account, string, string)

Gets a page of accounts which reblogged a status

statusId: identifier of the status
   limit: max amount of results per page (default: 40)

Returns a slice of accounts which reblogged the status and two urls pointing to the previous and next page respectively

func ListAccounts

func ListAccounts(baseUrl, accessToken, listId string, limit int) (error, []Account, string, string)

Gets a page of accounts in a list

listId: identifier for the list to retrieve
 limit: max amount of results per page (default: 0)

Returns a slice of accounts and two urls pointing to the previous and next page respectively

func SearchAccounts

func SearchAccounts(baseUrl, accessToken, query string, limit int, resolve, following bool) (error, []Account)

Queries all (federated) accounts for the given query (checks username, account and display name)

    query: the string to search for
    limit: maximum number of results per page (default: 40)
  resolve: attempt a webfinger lookup (default: false)
following: limit the search to accounts followed (default: false)

Returns a slice of accounts matching the query

func UpdateProfile

func UpdateProfile(baseUrl, accessToken, displayName, biography, locked, privacy, sensitive, language string, fields map[string]string) (error, Account)

Updates the account profile with the given values. Values set to "" (empty string) will not be updated, which allows to only update certain values.

displayName: Name shown on a users profile (does not change the username)
  biography: Description shown on a users profile
     locked: if an account is locked, following it will not immediately follow it but rather send a follow request
    privacy: Default privacy for statuses (public, unlisted or private)
  sensitive: Default sensitivity for statuses (true or false)
   language: Default language for posts (ISO6391, i.e. 'en')
     fields: Profile metadata (up to four title/value-pairs shown on a users profile)

Returns the updated account

func UpdateProfileAvatar

func UpdateProfileAvatar(baseUrl, accessToken, path string) (error, Account)

Updates the users profile avatar.

path: path to the image which should be uploaded and used as new avatar

Returns the updated account

func UpdateProfileHeader

func UpdateProfileHeader(baseUrl, accessToken, path string) (error, Account)

Updates the users profile header.

path: path to the image which should be uploaded and used as new header

Returns the updated account

func VerifyAccountCredentials

func VerifyAccountCredentials(baseUrl, accessToken string) (error, Account)

Verifies that the AccessToken is a valid token and associated with an account (tokens generated by authenticating using client credentials are not associated with an account and can't be used for account calls, like posting statuses, liking, reblogging, ...)

type AccountBook

type AccountBook struct {
	Current []Account
	Book
}

Book used to scroll through accounts

func GetAccountBlocksBook

func GetAccountBlocksBook(baseUrl, accessToken string, limit int) AccountBook

Gets a book of accounts the user has blocked.

limit: maximum amount of results per page

Returns an AccountBook which can be used to scroll through the pages of blocked accounts.

func GetEndorsementsBook

func GetEndorsementsBook(baseUrl, accessToken string, limit int) AccountBook

Gets a book which can be used to scroll through pages of accounts the user has endorsed (endorsed accounts are highlighted on the users profile)

limit: max amount of results per page

Returns an AccountBook which can be used to scroll through the pages or collect all pages at once

func GetFollowRequestsBook

func GetFollowRequestsBook(baseUrl, accessToken string, limit int) AccountBook

Gets a book which can be used to scroll through pages of open follower requests

limit: maximum amount of accounts to retrieve per page (default: 40)

Returns an AccountBook which can be used to scroll through the pages or collect all pages at once

func GetFollowedsBook

func GetFollowedsBook(baseUrl, accessToken, accountId string, limit int) AccountBook

Gets a book which can be used to scroll through pages of accounts followed by the given account

accountId: id of the account the followeds should be retrieved from
    limit: maximum amount of accounts to retrieve per page (default: 40)

Returns an AccountBook which can be used to scroll through the pages or collect all pages at once

Note that when accountId points to a local account, all followed accounts will be retrieved. If it points to a remote (federated) account, only local accounts will be retrieved.

func GetFollowersBook

func GetFollowersBook(baseUrl, accessToken, accountId string, limit int) AccountBook

Gets a book which can be used to scroll through pages of followers

accountId: id of the account the followers should be retrieved from
    limit: maximum amount of accounts to retrieve per page (default: 40)

Returns an AccountBook which can be used to scroll through the pages or collect all pages at once

Note that when accountId points to a local account, all followers will be retrieved. If it points to a remote (federated) account, only local accounts will be retrieved.

func GetMutesBook

func GetMutesBook(baseUrl, accessToken string, limit int) AccountBook

Gets a book used to scroll through pages of muted accounts

limit: max amount of results per page (default: 40)

Returns an AccountBook used to scroll through the pages or collect them all at once

func GetStatusFavouritedByBook

func GetStatusFavouritedByBook(baseUrl, statusId string, limit int) AccountBook

Gets a book used to scroll through the pages of accounts which favourited a status

statusId: identifier of the status
   limit: max amount of results per page (default: 40)

Returns an AccountBook which can be used to scroll through the pages or collect all at once

func GetStatusRebloggedByBook

func GetStatusRebloggedByBook(baseUrl, statusId string, limit int) AccountBook

Gets a book used to scroll through the pages of accounts which reblogged a status

statusId: identifier of the status
   limit: max amount of results per page (default: 40)

Returns an AccountBook which can be used to scroll through the pages or collect all at once

func ListAccountsBook

func ListAccountsBook(baseUrl, accessToken, listId string, limit int) AccountBook

Gets a book used to scroll through the pages of accounts in a list

listId: identifier for the list to retrieve
 limit: max amount of results per page (default: 0)

Returns an AccountBook used to scroll through the pages or collect all at once

func NewAccountBook

func NewAccountBook(accessToken string) AccountBook

Creates a new AccountBook

func (*AccountBook) All

func (book *AccountBook) All() []Account

Returns all available accounts. Warning: Can take a long time (receives a maximum of 80 accounts per second)

func (*AccountBook) Get

func (book *AccountBook) Get(url, accessToken string) (error, []Account, string, string)

Retrieves a given page

func (*AccountBook) Next

func (book *AccountBook) Next() []Account

Updates the book to the values from the next page

func (*AccountBook) Previous

func (book *AccountBook) Previous() []Account

Updates the book to the values from the previous page

func (*AccountBook) Update

func (book *AccountBook) Update(url string) []Account

Updates the book using the values retrieved from the given url

type Alerts

type Alerts struct {
	Follow    string `json:"follow"`    // Notify when receiving a new follower
	Favourite string `json:"favourite"` // Notify when a status is favourited
	Reblog    string `json:"reblog"`    // Notify when a status is reblogged
	Mention   string `json:"mention"`   // Notify when the user is mentioned
	Poll      string `json:"poll"`      // Notify on poll updates
}

Set of alerts which a subscription can be subscribed to TODO: Should be booleans, but server returns JSON strings

type App

type App struct {
	Id           string `json:"id"`            // The identifier of the app
	ClientName   string `json:"name"`          // The client name as shown in statuses and applications view
	Website      string `json:"website"`       // The website which provides more information on the client
	RedirectUri  string `json:"redirect_uri"`  // The OAuth redirect endpoint
	ClientId     string `json:"client_id"`     // The OAuth ClientId
	ClientSecret string `json:"client_secret"` // The OAuth ClientSecret
	VapidKey     string `json:"vapid_key"`     // The associated accounts VAPID key used by WebPush
}

The app retrieved when registering a client at a mastodon server

func RegisterApp

func RegisterApp(baseUrl, clientName, website, scope string, redirectUri ...string) (error, App)

Register your application as an OAuth application.

 clientName: the name of the application (is shown on statuses)
    website: a website providing more information about your application (optional)
     scopes: the boundaries of scopes which can be requested
redirectUri: a list of possible redirect uris (optional)

Returns an app with the application dataset (clientName, website, scope, redirectUris), clientId, clientSecret and vapidKey.

Note: the scopes set when registering the application don't actually request anything. They only specify which scopes could potentially be requested during the apps lifecycle.

func VerifyCredentials

func VerifyCredentials(baseUrl, accessToken string) (error, App)

Verifies that the AccessToken is at least a valid client token (contrary to an access token associated with an account). AccessTokens that are valid can be used to authorize the client but unless they were received using an authorization method, they can't be used to post statuses, update a profile or use other methods that require an account.

See tootsuite/mastodon/app/controllers/api/v1/apps/credentials_controller.rb: https://github.com/tootsuite/mastodon/blob/master/app/controllers/api/v1/apps/credentials_controller.rb

type Application

type Application struct {
	Name    string `json:"name"`    // Name of the application
	Website string `json:"website"` // Website of the application
}

Display data of the application used to post a status

type Attachment

type Attachment struct {
	Id          string `json:"id"`          // The local identifier of the attachment
	Type        string `json:"type"`        // The type of attachment (unknown, image, gifv or video)
	Url         string `json:"url"`         // Url pointing to the attachment on the server
	RemoteUrl   string `json:"remote_url"`  // Url pointing to the attachment on the original server (if the attachment was federated)
	PreviewUrl  string `json:"preview_url"` // Url pointing to a small preview version of the attachment
	TextUrl     string `json:"text_url"`    // Url pointing to the text version of the attachment
	Meta        Meta   `json:"meta"`        // Metadata of the attachment
	Description string `json:"description"` // A description of the attachment
}

Data of an attachment which can be added to a status

func UpdateMedia

func UpdateMedia(baseUrl, accessToken, attachmentId, description string, focusX, focusY float64) (error, Attachment)

Updates an existing attachment

description: description of the file (for screen readers and loading errors) (optional, max 420 characters))
     focusX: x-axis focal point, between 0.0 and 1.0 (default: 0.0)
     focusY: y-axis focal point, between 0.0 and 1.0 (default: 0.0)

Returns the updated attachment

func UploadMedia

func UploadMedia(baseUrl, accessToken, filePath, description string, focusX, focusY float64) (error, Attachment)

Uploads a new media object which can be used as attachment

   filePath: path to the file which should be uploaded
description: description of the file (for screen readers and loading errors) (optional, max 420 characters))
     focusX: x-axis focal point, between 0.0 and 1.0 (default: 0.0)
     focusY: y-axis focal point, between 0.0 and 1.0 (default: 0.0)

Returns the newly created attachment

type Book

type Book struct {
	// contains filtered or unexported fields
}

Helper struct for pagination

func (*Book) HasNext

func (book *Book) HasNext() bool

Checks if the book has a link to the next page

func (*Book) HasPrevious

func (book *Book) HasPrevious() bool

Checks if the book has a link to the previous page

type Card

type Card struct {
	Url          string  `json:"url"`           // Url the card is pointing
	Title        string  `json:"title"`         // Title of the card
	Description  string  `json:"description"`   // Description of the card
	Image        string  `json:"image"`         // Preview image for the url shown in the card
	Type         string  `json:"type"`          // The type of card (link, photo, video or rich)
	AuthorName   string  `json:"author_name"`   // Name of the author of the linked article/embeddable
	AuthorUrl    string  `json:"author_url"`    // Website of the author of the linked article/embeddable
	ProviderName string  `json:"provider_name"` // Name of the provider hosting the article/embeddable
	ProviderUrl  string  `json:"provider_url"`  // Website of the provider hosting the linked article/embeddable
	Html         string  `json:"html"`          // Html used when the card contains an embeddable
	Width        float32 `json:"width"`         // Width of the preview image
	Height       float32 `json:"height"`        // Height of the preview image
}

Card data used to generate a preview/embedding for links in statuses

func GetStatusCard

func GetStatusCard(baseUrl, id string) (error, Card)

Gets the card of a status

statusId: identifier of the status whose card to get

Returns the card

type Context

type Context struct {
	Ancestors   []Status `json:"ancestors"`   // Statuses preceding this status
	Descendants []Status `json:"descendants"` // Statuses following a status
}

The context of a status, used in conversations

func GetStatusContext

func GetStatusContext(baseUrl, statusId string) (error, Context)

Gets the context of a status

statusId: identifier of the status whose context to get

Returns the context

type Conversation

type Conversation struct {
	Id         string    `json:"id"`          // Identifier of this conversation
	Accounts   []Account `json:"accounts"`    // Accounts participating in the conversation
	LastStatus Status    `json:"last_status"` // The status which was posted last
	Unread     bool      `json:"unread"`      // True if the conversation has unread statuses
}

Data of a conversation

func GetConversations

func GetConversations(baseUrl, accessToken, maxId, sinceId, minId string, limit int) (error, []Conversation, string, string)

Gets a page of conversations

  maxId: only retrieve conversations with statuses before this status (optional)
sinceId: only retrieve conversations with statuses after this status (optional)
  minId: only retrieve conversations with statuses after this status (optional)
  limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of conversations and two urls pointing to the previous and next page respectively

type ConversationBook

type ConversationBook struct {
	Current []Conversation
	Book
}

Book used to scroll through statuses

func GetConversationsBook

func GetConversationsBook(baseUrl, accessToken string, limit int) ConversationBook

Gets a book used to scroll through the pages of conversations

limit: only retrieve this amount of statuses per page (default: 40)

Returns a ConversationBook used to scroll through the pages or collect them all at once

func NewConversationBook

func NewConversationBook(accessToken string) ConversationBook

Creates a new ConversationBook

func (*ConversationBook) All

func (book *ConversationBook) All() []Conversation

Returns all available statuses. Warning: Can take a long time (receives a maximum of 80 accounts per second)

func (*ConversationBook) Get

func (book *ConversationBook) Get(url, accessToken string) (error, []Conversation, string, string)

Retrieves the page of data and link-urls from the given url

func (*ConversationBook) Next

func (book *ConversationBook) Next() []Conversation

Updates the book to the values from the next page

func (*ConversationBook) Previous

func (book *ConversationBook) Previous() []Conversation

Updates the book to the values from the previous page

func (*ConversationBook) Update

func (book *ConversationBook) Update(url string) []Conversation

Updates the book using the values retrieved from the given url

type Emoji

type Emoji struct {
	ShortCode       string `json:"shortcode"`         // ShortCode of the emoji (used when 'writing' emojis, i.e. ':+1:' of which '+1' is the ShortCode of the thumbs-up emoji)
	StaticUrl       string `json:"static_url"`        // Url pointing to the static image of the emoji
	Url             string `json:"url"`               // Url pointing to the image of the emoji
	VisibleInPicker bool   `json:"visible_in_picker"` // True if the emoji should be visible in pickers
}

Data used for custom emojis

func GetCustomEmojis

func GetCustomEmojis(baseUrl string) (error, []Emoji)

Get a servers custom emojis

Returns a slice of emojis

type Error

type Error struct {
	Error string `json:"error"` // Contains the error
}

Data sent by the server to provide information why an action/request failed

type Field

type Field struct {
	Name       string `json:"name"`        // The name of the field, shown on the left side
	Value      string `json:"value"`       // The value of the field, shown on the right side
	VerifiedAt string `json:"verified_at"` // Timestamp of when the field was verified (or empty if not verified)
}

A field shown on a users profile (up to four fields can be set)

type Filter

type Filter struct {
	Id           string   `json:"id"`           // Identifier of the filter
	Phrase       string   `json:"phrase"`       // Phrase that is filtered
	Context      []string `json:"context"`      // Context the filter should be applied in (one or more of home, notifications, public and/or thread)
	ExpiresAt    string   `json:"expires_at"`   // Timestamp at which the filter expires
	Irreversible bool     `json:"irreversible"` // If the filter is irreversible, the filtered content will be deleted from the personal view instead of hidden. Therefore it can't be shown even if the filter is deleted or timed out.
	WholeWord    bool     `json:"whole_word"`   // True if the filter needs to match a whole word instead of matching anything
}

Data for a filter used to automatically hide statuses from users

func CreateFilter

func CreateFilter(baseUrl, accessToken, phrase string, context []string, irreversible, wholeWord bool, expiresIn int) (error, Filter)

Creates a new filter

      phrase: the phrase to be checked for in statuses
     context: the context(s) in which the filter should be applied (one or more of home, notifications, public and/or thread)
irreversible: if true, matching statuses will be dropped from the timeline instead of hidden (only works with context home and notifications) (default: false)
   wholeWord: whether to consider word boundaries when matching (default: false)
   expiresIn: time in seconds when the filter will expire or no-expiration when set to 0 (default: 0)

Returns the newly created filter

func GetFilter

func GetFilter(baseUrl, accessToken, filterId string) (error, Filter)

Get a specific filter

filterId: identifier of the filter to be retrieved

Returns the filter for the given id

func GetFilters

func GetFilters(baseUrl, accessToken string) (error, []Filter)

Get all currently setup filters

Returns a slice of filters

func UpdateFilter

func UpdateFilter(baseUrl, accessToken, filterId, phrase string, context []string, irreversible, wholeWord bool, expiresIn int) (error, Filter)

Updates an existing filter

      phrase: the phrase to be checked for in statuses
     context: the context(s) in which the filter should be applied (one or more of home, notifications, public and/or thread)
irreversible: if true, matching statuses will be dropped from the timeline instead of hidden (only works with context home and notifications) (default: false)
   wholeWord: whether to consider word boundaries when matching (default: false)
   expiresIn: time in seconds when the filter will expire or no-expiration when set to 0 (default: 0)

Returns the updated filter

type Focus

type Focus struct {
	X float32 `json:"x"` // X-Axis focal point of an attachment (between 0.0 and 1.0)
	Y float32 `json:"y"` // Y-Axis focal point of an attachment (between 0.0 and 1.0)
}

Focus data of an image, used to align the preview image

type History

type History struct {
	Day      string `json:"day"`      // Timestamp of the date this entry is referring to
	Uses     string `json:"uses"`     // Times the (hash) tag has been used at that day
	Accounts string `json:"accounts"` // Amount of different accounts who used the (hash) tag
}

A dated statistic of the uses for a (hash) tag

type Instance

type Instance struct {
	Uri            string   `json:"uri"`             // Uri of the mastodon instance
	Title          string   `json:"title"`           // Title of the mastodon instance
	Description    string   `json:"description"`     // Description of the mastodon instance
	Email          string   `json:"email"`           // Public contact email of the mastodon instance
	Version        string   `json:"version"`         // Version of the mastodon instance
	Thumbnail      string   `json:"thumbnail"`       // Url pointing to the thumbnail (preview) image of the mastodon instance
	Urls           URLs     `json:"urls"`            // Url pointing to the streaming api endpoint (Used by WebSockets)
	Stats          Stats    `json:"stats"`           // Statistics of the mastodon instance
	Languages      []string `json:"languages"`       // Official languages of the mastodon instance
	ContactAccount Account  `json:"contact_account"` // Administrator/official contact of the mastodon instance
}

Data used to provide information about a mastodon server

func GetInstance

func GetInstance(baseUrl string) (error, Instance)

Gets information about a server

Returns an instance

type List

type List struct {
	Id    string `json:"id"`    // Identifier for the list
	Title string `json:"title"` // Title of the list
}

Lists allow the creation of timelines which only contains statuses by a specified set of accounts

func CreateList

func CreateList(baseUrl, accessToken, title string) (error, List)

Creates a new list

title: title of the new list

Returns the newly created list

func GetList

func GetList(baseUrl, accessToken, listId string) (error, List)

Get a single list created by the user

listId: identifier of the list to retrieve

Returns a list

func GetLists

func GetLists(baseUrl, accessToken string) (error, []List)

Get all lists created by the user

Returns a slice of lists

func GetListsWithAccount

func GetListsWithAccount(baseUrl, accessToken, accountId string) (error, []List)

Get all lists containing an account

accountId: identifier for an account the lists should be queried for

Returns a slice of lists containing the account

func UpdateList

func UpdateList(baseUrl, accessToken, listId, title string) (error, List)

Updates a list

listId: identifier of the list to be updated
 title: the new title of the list

Returns the updated list

type Media

type Media struct {
	Path        string  // Path to the media file
	Description string  // A description of the media (optional)
	FocusX      float64 // The x-axis focus point (between 0.0 and 1.0)
	FocusY      float64 // The y-axis focus point (between 0.0 and 1.0)
}

A struct used when uploading media attachments within the status post call

type Mention

type Mention struct {
	Url      string `json:"url"`      // Url pointing to the url of the mentioned account
	Username string `json:"username"` // Username of the mentioned account
	Account  string `json:"acct"`     // Full account name (username@server.tld) or Username if the account belongs to the queried server
	Id       string `json:"id"`       // Identifier of the mentioned account
}

Data of a mentioned account

type Meta

type Meta struct {
	Focus    Focus          `json:"focus"`    // Focus point of an attachment
	Small    MetaAttributes `json:"small"`    // Set of attributes for the small (preview) version of an attachment
	Original MetaAttributes `json:"original"` // Set of attributes for the original version of an attachment
}

Metadata of an attachment

type MetaAttributes

type MetaAttributes struct {
	Width     float32 `json:"width"`      // Width of an attachment
	Height    float32 `json:"height"`     // Height of an attachment
	Size      string  `json:"size"`       // Size of an image attachment
	Aspect    float32 `json:"aspect"`     // Aspect ratio of an image attachment
	FrameRate string  `json:"frame_rate"` // Framerate of a gifv/video attachment
	Duration  float32 `json:"duration"`   // Duration of a gifv/video attachment
	Bitrate   float32 `json:"bitrate"`    // Bitrate of a gifv/video attachment
}

Metadata of an attachment

type Notification

type Notification struct {
	Id        string  `json:"id"`         // Identifier for the notification
	Type      string  `json:"type"`       // Type of notification (follow, mention, reblog or favourite)
	CreatedAt string  `json:"created_at"` // Timestamp of when the notification was generated
	Account   Account `json:"account"`    // The account which performed an action (followed, mentioned, reblogged or favourited)
	Status    Status  `json:"status"`     // The status which an action was performed on/with
}

Data of a notification

func GetNotification

func GetNotification(baseUrl, accessToken, notificationId string) (error, Notification)

Get a notification

notificationId: identifier of the notification to get

Returns the notifications

func GetNotifications

func GetNotifications(baseUrl, accessToken string, excludeTypes []string, accountId, maxId, sinceId, minId string, limit int) (error, []Notification, string, string)

Gets a page of notifications

excludeTypes: types to exclude (one or more of follow, favourite, reblog and/or mention)
   accountId: return notifications which were created due to actions performed by this account (optional)
       maxId: only retrieve statuses before this status (optional)
     sinceId: only retrieve statuses after this status (optional)
       minId: only retrieve statuses after this status (optional)
       limit: max amount of results per page (default: 20)

Returns a slice of notifications and two urls pointing to the previous and next url respectively

type NotificationBook

type NotificationBook struct {
	Current []Notification
	Book
}

Book used to scroll through statuses

func GetNotificationsBook

func GetNotificationsBook(baseUrl, accessToken string, excludeTypes []string, accountId string, limit int) NotificationBook

Gets a book used to scroll through pages of notifications

excludeTypes: types to exclude (one or more of follow, favourite, reblog and/or mention)
   accountId: return notifications which were created due to actions performed by this account (optional)
       limit: max amount of results per page (default: 20)

Returns a NotificationBook used to scroll through the pages or collect all at once

func NewNotificationBook

func NewNotificationBook(accessToken string) NotificationBook

Creates a new NotificationBook

func (*NotificationBook) All

func (book *NotificationBook) All() []Notification

Returns all available statuses. Warning: Can take a long time (receives a maximum of 80 accounts per second)

func (*NotificationBook) Get

func (book *NotificationBook) Get(url, accessToken string) (error, []Notification, string, string)

Retrieves the page of data and link-urls from the given url

func (*NotificationBook) Next

func (book *NotificationBook) Next() []Notification

Updates the book to the values from the next page

func (*NotificationBook) Previous

func (book *NotificationBook) Previous() []Notification

Updates the book to the values from the previous page

func (*NotificationBook) Update

func (book *NotificationBook) Update(url string) []Notification

Updates the book using the values retrieved from the given url

type Poll

type Poll struct {
	Id         string       `json:"id"`          // Identifier of the poll
	ExpiresAt  string       `json:"expires_at"`  // Timestamp of when the poll will expire/expired at
	Expired    bool         `json:"expired"`     // True if the poll already expired
	Multiple   bool         `json:"multiple"`    // True if the poll allows multiple-choice answers
	VotesCount int          `json:"votes_count"` // Amount of votes already posted (counts multiple-choice answers as multiple votes)
	Options    []PollOption `json:"options"`     // Options to choose from
	Voted      bool         `json:"voted"`       // True if the user already voted on this poll
}

Data of a poll

func GetPoll

func GetPoll(baseUrl, pollId string) (error, Poll)

Gets a poll

pollId:  identifier of the poll to get

Returns the poll

func VoteOnPoll

func VoteOnPoll(baseUrl, accessToken, pollId string, choices ...int) (error, Poll)

Posts a vote on a poll

pollId: identifier of the poll to vote on
choices: one (or more) ordinals of choices to vote on (multiple ordinals can only be used when the vote allows multiple choices)

Returns the updated poll

type PollOption

type PollOption struct {
	Title      string `json:"title"`       // Title of the choice
	VotesCount int    `json:"votes_count"` // Amount of votes for the choice
}

Data for a single choice in a poll

type PushSubscription

type PushSubscription struct {
	Id        int64  `json:"id"`         // Identifier of the subscription
	Endpoint  string `json:"endpoint"`   // Endpoint of the subscription
	ServerKey string `json:"server_key"` // ServerKey used for the subscription
	Alerts    Alerts `json:"alerts"`     // Alerts which are subscribed to
}

Data for the push subscription

func CreateSubscription

func CreateSubscription(baseUrl, accessToken, endpoint, p256dh, auth string, follow, favourite, reblog, mention, poll bool) (error, PushSubscription)

Creates a new subscription

 endpoint: url of the push endpoint
   p256dh: public key (Base64 encoded string of public key of ECDH key using ‘prime256v1’ curve)
     auth: auth secret (Base64 encoded string of 16 bytes of random data)
   follow: receive follow notifications
favourite: receive favourite notifications
   reblog: receive reblog notifications
  mention: receive mention notifications
     poll: receive poll notifications

Returns the newly created push subscription

func GetSubscription

func GetSubscription(baseUrl, accessToken string) (error, PushSubscription)

Gets the current subscription

func UpdateSubscription

func UpdateSubscription(baseUrl, accessToken string, follow, favourite, reblog, mention, poll bool) (error, PushSubscription)

Updates the subscription

   follow: receive follow notifications
favourite: receive favourite notifications
   reblog: receive reblog notifications
  mention: receive mention notifications
     poll: receive poll notifications

Returns the updated push subscription

type Relationship

type Relationship struct {
	Id                  string `json:"id"`                   // Identifier of the account
	Following           bool   `json:"following"`            // True if the user follows the account
	FollowedBy          bool   `json:"followed_by"`          // True if the account follows the user
	Blocking            bool   `json:"blocking"`             // True if the user blocks the account
	Muting              bool   `json:"muting"`               // True if the user muted the account
	MutingNotifications bool   `json:"muting_notifications"` // True if the user muted notifications for the account
	Requested           bool   `json:"requested"`            // True if the user sent a follow request to the account
	DomainBlocking      bool   `json:"domain_blocking"`      // True if the account is on a blocked domain
	ShowingReblogs      bool   `json:"showing_reblogs"`      // True if the user wants to see reblogs by the account
	Endorsed            bool   `json:"endorsed"`             // True if the user endorsed the account
}

Relationship data between two accounts

func BlockAccount

func BlockAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Blocks the given account.

accountId: the accountId associated with the account to be blocked

Returns the updated relationship

func EndorseAccount

func EndorseAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Endorses (pins) the given account

accountId: the account to endorse

Returns the updated relationship

func FollowAccount

func FollowAccount(baseUrl, accessToken, accountId string, hideReblogs string) (error, Relationship)

Follow the given account.

hideReblogs:  show/hide reblogs in timelines and such (default: false)

Returns the new relationship

func GetRelationships

func GetRelationships(baseUrl, accessToken string, accountIds ...string) (error, []Relationship)

Get the relationship to all given accounts

accountIds: Slice of accounts to return

Returns an slice containing a relationship for each given accountId

func MuteAccount

func MuteAccount(baseUrl, accessToken, accountId string, notifications bool) (error, Relationship)

Mutes an account

accountId: identifier of the account to be muted

notifications: if notifications for this account should be muted as well (default: true)

Returns the updated relationship

func UnblockAccount

func UnblockAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Unblocks the given account

accountId: the accountId associated with the account to be blocked

Returns the updated relationship

func UnendorseAccount

func UnendorseAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Unendorses (unpins) the given account

accountId: the account to unendorse

Returns the updated relationship

func UnfollowAccount

func UnfollowAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Unfollow the given account.

Returns the new relationship

func UnmuteAccount

func UnmuteAccount(baseUrl, accessToken, accountId string) (error, Relationship)

Unmutes an account

accountId: identifier of the account to be unmuted

Returns the updated relationship

type Result

type Result struct {
	Accounts []Account `json:"accounts"` // Accounts matching the query
	Statuses []Status  `json:"statuses"` // Statuses matching the query
	Hashtags []Tag     `json:"hashtags"` // Tags matching the query
}

Set of search results

func Search(baseUrl, accessToken, query string, resolve, following bool, limit, offset int) (error, Result)

Search accounts, statuses and tags

query: query to look for
resolve: attempt a WebFinger lookup (default: false)
following: only include accounts the user is following (default: false)
limit: max number of results (default: 40)
offset: result offset of the search (used for pagination) (default: 0)

Returns a result, containing individual slices for accounts, statuses and tags

type ScheduledStatus

type ScheduledStatus struct {
	Id               string       `json:"id"`                // Identifier for the scheduled status
	ScheduledAt      string       `json:"scheduled_at"`      // Timestamp at which the status will be posted
	Params           StatusParams `json:"params"`            // Parameters of the status which will be posted
	MediaAttachments []Attachment `json:"media_attachments"` // Attachments of the status which will be posted
}

Data of a scheduled status

func GetScheduledStatus

func GetScheduledStatus(baseUrl, accessToken, scheduledId string) (error, ScheduledStatus)

Gets a scheduled status

scheduledId: identifier of the scheduled status to get

Returns the scheduled status

func GetScheduledStatuses

func GetScheduledStatuses(baseUrl, accessToken string) (error, []ScheduledStatus)

Get all scheduled statuses

Returns a slice of scheduled statuses

func ScheduleMediaStatus

func ScheduleMediaStatus(baseUrl, accessToken, status, scheduledAt, inReplyToId string, mediaIds []string, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, ScheduledStatus)

Schedules a new media status

        status: the text of the status
   scheduledAt: timestamp of when the status will be posted
   inReplyToId: identifier of the status it will reply to (optional)
      mediaIds: identifiers of attachments (media status)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly scheduled status

func SchedulePollStatus

func SchedulePollStatus(baseUrl, accessToken, status, scheduledAt, inReplyToId string, pollOptions []string, pollExpiresIn int, pollMultiple, pollHideTotals, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, ScheduledStatus)

Schedules a new poll

        status: the text of the status
   scheduledAt: timestamp of when the status will be posted
   inReplyToId: identifier of the status it will reply to (optional)
   pollOptions: options for the poll (poll status)
 pollExpiresIn: time in seconds the poll will be live (poll status) (default: DurationDay)
  pollMultiple: set to true to allow multiple choices (poll status) (default: false)
pollHideTotals: set to true to hide the results while the poll is live (poll status) (default: false)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly scheduled status

func ScheduleStatus

func ScheduleStatus(baseUrl, accessToken, status, scheduledAt, inReplyToId string, mediaIds []string, pollOptions []string, pollExpiresIn int, pollMultiple, pollHideTotals, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, ScheduledStatus)

Schedules a new status

        status: the text of the status
   scheduledAt: timestamp of when the status will be posted
   inReplyToId: identifier of the status it will reply to (optional)
      mediaIds: identifiers of attachments (media status)
   pollOptions: options for the poll (poll status)
 pollExpiresIn: time in seconds the poll will be live (poll status) (default: DurationDay)
  pollMultiple: set to true to allow multiple choices (poll status) (default: false)
pollHideTotals: set to true to hide the results while the poll is live (poll status) (default: false)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly scheduled status

func ScheduleTextStatus

func ScheduleTextStatus(baseUrl, accessToken, status, scheduledAt, inReplyToId string, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, ScheduledStatus)

Schedules a new text status

        status: the text of the status
   scheduledAt: timestamp of when the status will be posted
   inReplyToId: identifier of the status it will reply to (optional)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly scheduled status

func UpdateScheduledStatus

func UpdateScheduledStatus(baseUrl, accessToken, scheduledId, scheduledAt string) (error, ScheduledStatus)

Moves a scheduled status to a new time

scheduledId: identifier of the scheduled status to be updated
scheduledAt: timestamp of when the status should be scheduled

Returns the updated scheduled status

func UploadAndScheduleMediaStatus

func UploadAndScheduleMediaStatus(baseUrl, accessToken, status, scheduledAt, inReplyToId string, medias []Media, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, ScheduledStatus)

Uploads any attachments and schedules a new media status

        status: the text of the status
   scheduledAt: timestamp of when the status will be posted
   inReplyToId: identifier of the status it will reply to (optional)
        medias: slice of medias which should be uploaded and attached (optional)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly scheduled status

type Source

type Source struct {
	Privacy   string  `json:"privacy"`   // The default set visibility of statuses (public, private, unlisted, direct)
	Sensitive bool    `json:"sensitive"` // The default sensitivity setting of statuses
	Language  string  `json:"language"`  // The default language of statuses
	Note      string  `json:"note"`      // Description/Biography of the account
	Fields    []Field `json:"fields"`    // Array of up to four fields shown on the profile
}

Source data of an account

type Stats

type Stats struct {
	UserCount   int64 `json:"user_count"`   // Amount of users registered at the mastodon instance
	StatusCount int64 `json:"status_count"` // Amount of statuses posted by members of the mastodon instance
	DomainCount int64 `json:"domain_count"` // Amount of domains federated on the mastodon instance
}

Statistics for a mastodon server

type Status

type Status struct {
	Id                 string       `json:"id"`                     // Identifier for the status
	Uri                string       `json:"uri"`                    // Uri pointing to the status
	Url                string       `json:"url"`                    // Url pointing to the status
	Account            Account      `json:"account"`                // Account which posted the status
	InReplyToId        string       `json:"in_reply_to_id"`         // Identifier of the status replied to
	InReplyToAccountId string       `json:"in_reply_to_account_id"` // Identifier of the account replied to
	Reblog             *Status      `json:"reblog"`                 // Status which was reblogged
	Content            string       `json:"content"`                // Content of the status
	CreatedAt          string       `json:"created_at"`             // Timestamp of when the status was created
	Emojis             []Emoji      `json:"emojis"`                 // Set of emojis used in the status
	RepliesCount       int          `json:"replies_count"`          // Amount of replies given to the status
	ReblogsCount       int          `json:"reblogs_count"`          // Amount of times the status was reblogged
	FavouritesCount    int          `json:"favourites_count"`       // Amount of favourites the status received
	Reblogged          bool         `json:"reblogged"`              // True if the user reblogged the status
	Favourited         bool         `json:"favourited"`             // True if the user favourited the status
	Muted              bool         `json:"muted"`                  // True if the user muted the status
	Sensitive          bool         `json:"sensitive"`              // True if the content of the status should be marked sensitive
	SpoilerText        string       `json:"spoiler_text"`           // Text shown if the status is sensitive
	Visibility         string       `json:"visibility"`             // Visibility of the status (public, private, unlisted or direct)
	MediaAttachments   []Attachment `json:"media_attachments"`      // Attachments of the status
	Mentions           []Mention    `json:"mentions"`               // Other accounts mentioned in the status
	Tags               []Tag        `json:"tags"`                   // Tags in the status
	Card               Card         `json:"card"`                   // Card data of the status
	Poll               Poll         `json:"poll"`                   // Poll data of the status
	Application        Application  `json:"application"`            // Application which posted the status
	Language           string       `json:"language"`               // Language of the content
	Pinned             bool         `json:"pinned"`                 // True if the status is pinned
}

Data of a status

func FavouriteStatus

func FavouriteStatus(baseUrl, accessToken, statusId string) (error, Status)

Favourites a status

statusId: identifier of the status which should be favourited

Returns the status

func GetFavourites

func GetFavourites(baseUrl, accessToken string, limit int) (error, []Status, string, string)

Gets a single page of statuses favourited by the user

limit: maximum amount of accounts to retrieve (default: 40)

Returns a slice of favourited statuses and two urls pointing to the next and previous page respectively

func GetHashtagTimeline

func GetHashtagTimeline(baseUrl, accessToken, hashTag string, local, onlyMedia bool, maxId, sinceId, minId string, limit int) (error, []Status, string, string)

Gets a page of statuses in a hashtags timeline

	  hashTag: the hashtag whose timeline to retrieve
     local: only retrieve local statuses (default: false)
	onlyMedia: only retrieve statuses with attachments (default: false)
	    maxId: only retrieve statuses before this status (optional)
	  sinceId: only retrieve statuses after this status (optional)
	    minId: only retrieve statuses after this status (optional)
	    limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of statuses and two urls pointing to the previous and next page respectively

func GetHomeTimeline

func GetHomeTimeline(baseUrl, accessToken, maxId, sinceId, minId string, limit int) (error, []Status, string, string)

Gets a page of statuses in the home timeline

  maxId: only retrieve statuses before this status (optional)
sinceId: only retrieve statuses after this status (optional)
  minId: only retrieve statuses after this status (optional)
  limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of statuses and two urls pointing to the previous and next page respectively

func GetListTimeline

func GetListTimeline(baseUrl, accessToken, listId, maxId, sinceId, minId string, limit int) (error, []Status, string, string)

Gets a page of statuses in a lists timeline

 listId: identifier of the list whose timeline to retrieve
  maxId: only retrieve statuses before this status (optional)
sinceId: only retrieve statuses after this status (optional)
  minId: only retrieve statuses after this status (optional)
  limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of statuses and two urls pointing to the previous and next page respectively

func GetPublicTimeline

func GetPublicTimeline(baseUrl, accessToken string, local, onlyMedia bool, maxId, sinceId, minId string, limit int) (error, []Status, string, string)

Gets a page of statuses in the public timeline

     local: only retrieve local statuses (default: false)
	onlyMedia: only retrieve statuses with attachments (default: false)
	    maxId: only retrieve statuses before this status (optional)
	  sinceId: only retrieve statuses after this status (optional)
	    minId: only retrieve statuses after this status (optional)
	    limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of statuses and two urls pointing to the previous and next page respectively

func GetStatus

func GetStatus(baseUrl, statusId string) (error, Status)

Gets a status

statusId: identifier of the status to get

Returns the status

func GetStatusesOfAccount

func GetStatusesOfAccount(baseUrl, accessToken, accountId string, onlyMedia, onlyPinned, excludeReplies, excludeReblogs bool, maxId, sinceId, minId string, limit int) (error, []Status, string, string)

Gets a page of statuses (visible to the user) posted by the given account.

     onlyMedia: only retrieve statuses which include media (default: false)
    onlyPinned: only retrieve statuses which are pinned (default: false)
excludeReplies: exclude statuses which reply to other statuses (default: false)
excludeReblogs: exclude reblogs (default: false)
         maxId: only retrieve statuses before this status (optional)
       sinceId: only retrieve statuses after this status (optional)
         minId: only retrieve statuses after this status (optional)
         limit: only retrieve this amount of statuses per page (default: 40)

Returns a slice of statuses and two urls pointing to the next and previous page respectively

Note that when AccountId points to a local account, all statuses will be retrieved. If it points to a remote (federated) account, only statuses posted after it first appeared to the server will be retrieved.

func MuteStatus

func MuteStatus(baseUrl, accessToken, statusId string) (error, Status)

Mutes a status

statusId: identifier of the status to be muted

Returns the status

func PinStatus

func PinStatus(baseUrl, accessToken, statusId string) (error, Status)

Pins a status

statusId: identifier of the status to be pinned

func PostMediaStatus

func PostMediaStatus(baseUrl, accessToken, status, inReplyToId string, mediaIds []string, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, Status)

Posts a new media status

        status: the text of the status
   inReplyToId: identifier of the status it will reply to (optional)
      mediaIds: identifiers of attachments (media status)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly posted status

func PostPollStatus

func PostPollStatus(baseUrl, accessToken, status, inReplyToId string, pollOptions []string, pollExpiresIn int, pollMultiple, pollHideTotals, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, Status)

Posts a new poll

        status: the text of the status
   inReplyToId: identifier of the status it will reply to (optional)
   pollOptions: options for the poll (poll status)
 pollExpiresIn: time in seconds the poll will be live (poll status) (default: DurationDay)
  pollMultiple: set to true to allow multiple choices (poll status) (default: false)
pollHideTotals: set to true to hide the results while the poll is live (poll status) (default: false)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly posted status

func PostStatus

func PostStatus(baseUrl, accessToken, status, inReplyToId string, mediaIds []string, pollOptions []string, pollExpiresIn int, pollMultiple, pollHideTotals, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, Status)

Posts a new status

        status: the text of the status
   inReplyToId: identifier of the status it will reply to (optional)
      mediaIds: identifiers of attachments (media status)
   pollOptions: options for the poll (poll status)
 pollExpiresIn: time in seconds the poll will be live (poll status) (default: DurationDay)
  pollMultiple: set to true to allow multiple choices (poll status) (default: false)
pollHideTotals: set to true to hide the results while the poll is live (poll status) (default: false)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly posted status

func PostTextStatus

func PostTextStatus(baseUrl, accessToken, status, inReplyToId string, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, Status)

Posts a new text status

        status: the text of the status
   inReplyToId: identifier of the status it will reply to (optional)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly posted status

func ReblogStatus

func ReblogStatus(baseUrl, accessToken, statusId string) (error, Status)

Reblogs a status

statusId: identifier of the status to be reblogged

func UnfavouriteStatus

func UnfavouriteStatus(baseUrl, accessToken, statusId string) (error, Status)

Unfavourites a status

statusId: identifier of the status which should be unfavourited

Returns the status

func UnmuteStatus

func UnmuteStatus(baseUrl, accessToken, statusId string) (error, Status)

Unmutes a status

statusId: identifier of the status to be unmuted

Returns the status

func UnpinStatus

func UnpinStatus(baseUrl, accessToken, statusId string) (error, Status)

Unpins a status

statusId: identifier of the status to be unpinned

func UnreblogStatus

func UnreblogStatus(baseUrl, accessToken, statusId string) (error, Status)

Unreblogs a status

statusId: identifier of the status to be unreblogged

func UploadAndPostMediaStatus

func UploadAndPostMediaStatus(baseUrl, accessToken, status, inReplyToId string, medias []Media, sensitive bool, spoilerText, visibility, language, idempotencyKey string) (error, Status)

Uploads any attachments and posts a new media status

        status: the text of the status
   inReplyToId: identifier of the status it will reply to (optional)
      mediaIds: identifiers of attachments (media status)
     sensitive: set to true if the post contains sensitive content (default: false)
   spoilerText: text which will be shown instead if the status is marked as sensitive (optional)
    visibility: visibility of the status (either public, private, unlisted or direct) (default: public)
      language: the language of the status (ISO 8601) (optional)
idempotencyKey: helps preventing duplicate posts (optional)

Returns the newly posted status

type StatusBook

type StatusBook struct {
	Current []Status
	Book
}

Book used to scroll through statuses

func GetFavouritesBook

func GetFavouritesBook(baseUrl, accessToken string, limit int) StatusBook

Gets a book which can be used to scroll through pages of statuses favourited by the user

limit: maximum amount of accounts to retrieve per page (default: 40)

Returns a StatusBook which can be used to scroll through the pages or collect all pages at once

func GetHashtagTimelineBook

func GetHashtagTimelineBook(baseUrl, accessToken, hashTag string, local, onlyMedia bool, limit int) StatusBook

Gets a book used to scroll through the pages of statuses in a hashtags timeline

	  hashTag: the hashtag whose timeline to retrieve
     local: only retrieve local statuses (default: false)
	onlyMedia: only retrieve statuses with attachments (default: false)
	    limit: only retrieve this amount of statuses per page (default: 40)

Returns a StatusBook used to scroll through the pages or collect them all at once

func GetHomeTimelineBook

func GetHomeTimelineBook(baseUrl, accessToken string, limit int) StatusBook

Gets a book used to scroll through the pages of statuses in the home timeline

limit: only retrieve this amount of statuses per page (default: 40)

Returns a StatusBook used to scroll through the pages or collect them all at once

func GetListTimelineBook

func GetListTimelineBook(baseUrl, accessToken, listId string, limit int) StatusBook

Gets a book used to scroll through the pages of statuses in a lists timeline

listId: identifier of the list whose timeline to retrieve
 limit: only retrieve this amount of statuses per page (default: 40)

Returns a StatusBook used to scroll through the pages or collect them all at once

func GetPublicTimelineBook

func GetPublicTimelineBook(baseUrl, accessToken string, local, onlyMedia bool, limit int) StatusBook

Gets a book used to scroll through the pages of statuses in the public timeline

     local: only retrieve local statuses (default: false)
	onlyMedia: only retrieve statuses with attachments (default: false)
	    limit: only retrieve this amount of statuses per page (default: 40)

Returns a StatusBook used to scroll through the pages or collect them all at once

func GetStatusesOfAccountBook

func GetStatusesOfAccountBook(baseUrl, accessToken, accountId string, onlyMedia, onlyPinned, excludeReplies, excludeReblogs bool, limit int) StatusBook

Gets a book which can be used to scroll through pages of statuses (visible to the user) posted by the given account.

     onlyMedia: only retrieve statuses which include media (default: false)
    onlyPinned: only retrieve statuses which are pinned (default: false)
excludeReplies: exclude statuses which reply to other statuses (default: false)
excludeReblogs: exclude reblogs (default: false)
         limit: only retrieve this amount of statuses per page (default: 40)

Returns an StatusBook which can be used to scroll through the pages or collect all pages at once

Note that when accountId points to a local account, all statuses will be retrieved. If it points to a remote (federated) account, only statuses posted after it first appeared to the server will be retrieved.

func NewStatusBook

func NewStatusBook(accessToken string) StatusBook

Creates a new StatusBook

func (*StatusBook) All

func (book *StatusBook) All() []Status

Returns all available statuses. Warning: Can take a long time (receives a maximum of 80 accounts per second)

func (*StatusBook) Get

func (book *StatusBook) Get(url, accessToken string) (error, []Status, string, string)

Retrieves the page of data and link-urls from the given url

func (*StatusBook) Next

func (book *StatusBook) Next() []Status

Updates the book to the values from the next page

func (*StatusBook) Previous

func (book *StatusBook) Previous() []Status

Updates the book to the values from the previous page

func (*StatusBook) Update

func (book *StatusBook) Update(url string) []Status

Updates the book using the values retrieved from the given url

type StatusParams

type StatusParams struct {
	Text          string   `json:"text"`           // Content of the status
	InReplyToId   string   `json:"in_reply_to_id"` // Identifier of the status it replies to
	MediaIds      []string `json:"media_ids"`      // Identifiers of the attachments added to the status
	Sensitive     string   `json:"sensitive"`      // True if the status will be sensitive
	SpoilerText   string   `json:"spoiler_text"`   // Text shown if the status is sensitive
	Visibility    string   `json:"visibility"`     // Visibility of the status (public, private, unlisted or direct)
	ScheduledAt   string   `json:"scheduled_at"`   // Timestamp at which the status will be posted
	ApplicationId int64    `json:"application_id"` // Identifier of the application which scheduled the status
}

Data of a status that is yet to be posted

type StringBook

type StringBook struct {
	Current []string
	Book
}

Book used to scroll through statuses

func GetDomainBlocksBook

func GetDomainBlocksBook(baseUrl, accessToken string, limit int) StringBook

Gets a book which can be used to scroll through pages of domains the user has blocked

limit: max amount of results per page

Returns a StringBook which can be used to scroll through the pages or collect all pages at once

func NewStringBook

func NewStringBook(accessToken string) StringBook

Creates a new StringBook

func (*StringBook) All

func (book *StringBook) All() []string

Returns all available statuses. Warning: Can take a long time (receives a maximum of 80 accounts per second)

func (*StringBook) Get

func (book *StringBook) Get(url, accessToken string) (error, []string, string, string)

Retrieves the page of data and link-urls from the given url

func (*StringBook) Next

func (book *StringBook) Next() []string

Updates the book to the values from the next page

func (*StringBook) Previous

func (book *StringBook) Previous() []string

Updates the book to the values from the previous page

func (*StringBook) Update

func (book *StringBook) Update(url string) []string

Updates the book using the values retrieved from the given url

type Tag

type Tag struct {
	Name    string    `json:"name"`    // Name of the (hash) tag
	Url     string    `json:"url"`     // Url pointing to a timeline of statuses containing the (hash) tag
	History []History `json:"history"` // Historic data of uses for the (hash) tag
}

Data of a (hash) tag

type Token

type Token struct {
	AccessToken string `json:"access_token"` // The OAuth access token
	TokenType   string `json:"token_type"`   // The type of token (normally Bearer)
	Scope       string `json:"scope"`        // Scope of the token
	CreatedAt   int64  `json:"created_at"`   // Timestamp of when the token was generated
}

Token data retrieved when authorizing a client

func CreateAccount

func CreateAccount(baseUrl, accessToken, username, email, password string, agreement bool, locale string) (error, Token)

Creates a new account with the given username, email and password.

This can only be used when the client authenticated itself using client credentials.

	 username: the accounts username. Used as displayName if no other is set and used when tagging people
            (@username@domain.tld). Usernames can't be changed, but a profile can be moved to a new username
            which will change the username but break all associated statuses, follows, ...
	    email: the initial email address, which will receive the "Confirm Account" email
	 password: the initial password
	agreement: agree or disagree to the locale rules, terms of use and privacy policy
    locale: language of the initial email (ISO6391, i.e. 'en')

Returns a new access token associated with the account, which replaces the previous token

func GetAccessTokenFromAuthorizationCode

func GetAccessTokenFromAuthorizationCode(baseUrl, clientId, clientSecret, authorizationCode, scope, redirectUri string) (error, Token)

Exchanges an authorization code for an access token

authorizationCode: the authorization code received from the user
            scope: space-separated list of scopes to be authorized for
      redirectUri: uri the user will be redirected to, which will have the access token attached as url param (default: urn:ietf:wg:oauth:2.0:oob)

Returns a new token

func GetAccessTokenFromCredentials

func GetAccessTokenFromCredentials(baseUrl, clientId, clientSecret, scope string) (error, Token)

Gets a token by authorizing the application using its client credentials.

scope: space-separated list of scopes to be authorized for

Returns a new token

Note: the token received from this method is an application token, not an account token. It can be used for functions which require an authentication, but will fail for all functions requiring a user (like posting a status, ...).

func GetAccessTokenFromLogin

func GetAccessTokenFromLogin(baseUrl, clientId, clientSecret, username, password, scope, redirectUri string) (error, Token)

Gets a token using login credentials

    username: username to log in with
    password: password to log in with
       scope: space-separated list of scopes to be authorized for
	redirectUri: uri the user will be redirected to, which will have the access token attached as url param (default: urn:ietf:wg:oauth:2.0:oob)

Returns a new token

type URLs

type URLs struct {
	StreamingAPI string `json:"streaming_api"` // Url pointing to the streaming api endpoint (Used by WebSockets)
}

Data pointing to a endpoint which can be used by WebSockets

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL