Documentation ¶
Index ¶
- func Bool(v bool) *bool
- func CheckResponse(r *http.Response) error
- func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error)
- func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func FromEnv(c *Client) error
- func Int(v int) *int
- func StreamDiscardInitial(c *streamConfig)
- func String(v string) *string
- type APIError
- type AccountService
- func (s *AccountService) AddTrusted(ctx context.Context, username string) (*Response, error)
- func (s *AccountService) Blocked(ctx context.Context) ([]Relationship, *Response, error)
- func (s *AccountService) Friends(ctx context.Context) ([]Relationship, *Response, error)
- func (s *AccountService) Info(ctx context.Context) (*User, *Response, error)
- func (s *AccountService) Karma(ctx context.Context) ([]SubredditKarma, *Response, error)
- func (s *AccountService) Messaging(ctx context.Context) ([]Relationship, []Relationship, *Response, error)
- func (s *AccountService) RemoveTrusted(ctx context.Context, username string) (*Response, error)
- func (s *AccountService) Settings(ctx context.Context) (*Settings, *Response, error)
- func (s *AccountService) Trophies(ctx context.Context) ([]Trophy, *Response, error)
- func (s *AccountService) Trusted(ctx context.Context) ([]Relationship, *Response, error)
- func (s *AccountService) UpdateSettings(ctx context.Context, settings *Settings) (*Settings, *Response, error)
- type Ban
- type BanConfig
- type Bans
- type Blocked
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRequest(method string, path string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequestWithForm(method string, path string, form url.Values) (*http.Request, error)
- func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
- func (c *Client) UserAgent() string
- type Collection
- type CollectionCreateRequest
- type CollectionService
- func (s *CollectionService) AddPost(ctx context.Context, postID, collectionID string) (*Response, error)
- func (s *CollectionService) Create(ctx context.Context, createRequest *CollectionCreateRequest) (*Collection, *Response, error)
- func (s *CollectionService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *CollectionService) Follow(ctx context.Context, id string) (*Response, error)
- func (s *CollectionService) FromSubreddit(ctx context.Context, id string) ([]*Collection, *Response, error)
- func (s *CollectionService) Get(ctx context.Context, id string) (*Collection, *Response, error)
- func (s *CollectionService) RemovePost(ctx context.Context, postID, collectionID string) (*Response, error)
- func (s *CollectionService) ReorderPosts(ctx context.Context, collectionID string, postIDs ...string) (*Response, error)
- func (s *CollectionService) Unfollow(ctx context.Context, id string) (*Response, error)
- func (s *CollectionService) UpdateDescription(ctx context.Context, id string, description string) (*Response, error)
- func (s *CollectionService) UpdateLayoutGallery(ctx context.Context, id string) (*Response, error)
- func (s *CollectionService) UpdateLayoutTimeline(ctx context.Context, id string) (*Response, error)
- func (s *CollectionService) UpdateTitle(ctx context.Context, id string, title string) (*Response, error)
- type Comment
- type CommentService
- func (s CommentService) Delete(ctx context.Context, id string) (*Response, error)
- func (s CommentService) DisableReplies(ctx context.Context, id string) (*Response, error)
- func (s CommentService) Downvote(ctx context.Context, id string) (*Response, error)
- func (s *CommentService) Edit(ctx context.Context, id string, text string) (*Comment, *Response, error)
- func (s CommentService) EnableReplies(ctx context.Context, id string) (*Response, error)
- func (s *CommentService) LoadMoreReplies(ctx context.Context, comment *Comment) (*Response, error)
- func (s CommentService) Lock(ctx context.Context, id string) (*Response, error)
- func (s CommentService) RemoveVote(ctx context.Context, id string) (*Response, error)
- func (s CommentService) Report(ctx context.Context, id string, reason string) (*Response, error)
- func (s CommentService) Save(ctx context.Context, id string) (*Response, error)
- func (s *CommentService) Submit(ctx context.Context, parentID string, text string) (*Comment, *Response, error)
- func (s CommentService) Unlock(ctx context.Context, id string) (*Response, error)
- func (s CommentService) Unsave(ctx context.Context, id string) (*Response, error)
- func (s CommentService) Upvote(ctx context.Context, id string) (*Response, error)
- type Comments
- type Credentials
- type Emoji
- type EmojiCreateOrUpdateRequest
- type EmojiService
- func (s *EmojiService) Delete(ctx context.Context, subreddit string, emoji string) (*Response, error)
- func (s *EmojiService) DisableCustomSize(ctx context.Context, subreddit string) (*Response, error)
- func (s *EmojiService) Get(ctx context.Context, subreddit string) ([]*Emoji, []*Emoji, *Response, error)
- func (s *EmojiService) SetSize(ctx context.Context, subreddit string, height, width int) (*Response, error)
- func (s *EmojiService) Update(ctx context.Context, subreddit string, ...) (*Response, error)
- func (s *EmojiService) Upload(ctx context.Context, subreddit string, ...) (*Response, error)
- type ErrorResponse
- type Flair
- type FlairService
- func (s *FlairService) GetPostFlairs(ctx context.Context, subreddit string) ([]*Flair, *Response, error)
- func (s *FlairService) GetUserFlairs(ctx context.Context, subreddit string) ([]*Flair, *Response, error)
- func (s *FlairService) ListUserFlairs(ctx context.Context, subreddit string) ([]*FlairSummary, *Response, error)
- type FlairSummary
- type GoldService
- type JSONErrorResponse
- type ListDuplicatePostOptions
- type ListModActionOptions
- type ListOptions
- type ListPostOptions
- type ListPostSearchOptions
- type ListSubredditOptions
- type ListUserOverviewOptions
- type ListingsService
- type Message
- type MessageService
- func (s *MessageService) Block(ctx context.Context, id string) (*Response, error)
- func (s *MessageService) Collapse(ctx context.Context, ids ...string) (*Response, error)
- func (s *MessageService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *MessageService) Inbox(ctx context.Context, opts *ListOptions) (*Messages, *Messages, *Response, error)
- func (s *MessageService) InboxUnread(ctx context.Context, opts *ListOptions) (*Messages, *Messages, *Response, error)
- func (s *MessageService) Read(ctx context.Context, ids ...string) (*Response, error)
- func (s *MessageService) ReadAll(ctx context.Context) (*Response, error)
- func (s *MessageService) Send(ctx context.Context, sendRequest *SendMessageRequest) (*Response, error)
- func (s *MessageService) Sent(ctx context.Context, opts *ListOptions) (*Messages, *Response, error)
- func (s *MessageService) Uncollapse(ctx context.Context, ids ...string) (*Response, error)
- func (s *MessageService) Unread(ctx context.Context, ids ...string) (*Response, error)
- type Messages
- type ModAction
- type ModActions
- type ModPermissions
- type ModerationService
- func (s *ModerationService) AcceptInvite(ctx context.Context, subreddit string) (*Response, error)
- func (s *ModerationService) Approve(ctx context.Context, id string) (*Response, error)
- func (s *ModerationService) ApproveUser(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) ApproveUserWiki(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) Ban(ctx context.Context, subreddit string, username string, config *BanConfig) (*Response, error)
- func (s *ModerationService) BanWiki(ctx context.Context, subreddit string, username string, config *BanConfig) (*Response, error)
- func (s *ModerationService) Edited(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Comments, *Response, error)
- func (s *ModerationService) GetActions(ctx context.Context, subreddit string, opts *ListModActionOptions) (*ModActions, *Response, error)
- func (s *ModerationService) IgnoreReports(ctx context.Context, id string) (*Response, error)
- func (s *ModerationService) Invite(ctx context.Context, subreddit string, username string, ...) (*Response, error)
- func (s *ModerationService) Leave(ctx context.Context, subredditID string) (*Response, error)
- func (s *ModerationService) LeaveContributor(ctx context.Context, subredditID string) (*Response, error)
- func (s *ModerationService) Mute(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) Remove(ctx context.Context, id string) (*Response, error)
- func (s *ModerationService) RemoveSpam(ctx context.Context, id string) (*Response, error)
- func (s *ModerationService) SetPermissions(ctx context.Context, subreddit string, username string, ...) (*Response, error)
- func (s *ModerationService) UnapproveUser(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) UnapproveUserWiki(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) Unban(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) UnbanWiki(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) UnignoreReports(ctx context.Context, id string) (*Response, error)
- func (s *ModerationService) Uninvite(ctx context.Context, subreddit string, username string) (*Response, error)
- func (s *ModerationService) Unmute(ctx context.Context, subreddit string, username string) (*Response, error)
- type Moderator
- type More
- type Multi
- type MultiCopyRequest
- type MultiCreateOrUpdateRequest
- type MultiService
- func (s *MultiService) AddSubreddit(ctx context.Context, multiPath string, subreddit string) (*Response, error)
- func (s *MultiService) Copy(ctx context.Context, copyRequest *MultiCopyRequest) (*Multi, *Response, error)
- func (s *MultiService) Create(ctx context.Context, createRequest *MultiCreateOrUpdateRequest) (*Multi, *Response, error)
- func (s *MultiService) Delete(ctx context.Context, multiPath string) (*Response, error)
- func (s *MultiService) DeleteSubreddit(ctx context.Context, multiPath string, subreddit string) (*Response, error)
- func (s *MultiService) Get(ctx context.Context, multiPath string) (*Multi, *Response, error)
- func (s *MultiService) GetDescription(ctx context.Context, multiPath string) (string, *Response, error)
- func (s *MultiService) Mine(ctx context.Context) ([]Multi, *Response, error)
- func (s *MultiService) Of(ctx context.Context, username string) ([]Multi, *Response, error)
- func (s *MultiService) Update(ctx context.Context, multiPath string, ...) (*Multi, *Response, error)
- func (s *MultiService) UpdateDescription(ctx context.Context, multiPath string, description string) (string, *Response, error)
- type Opt
- type Post
- type PostAndComments
- type PostService
- func (s *PostService) ClearSuggestedSort(ctx context.Context, id string) (*Response, error)
- func (s PostService) Delete(ctx context.Context, id string) (*Response, error)
- func (s *PostService) DisableContestMode(ctx context.Context, id string) (*Response, error)
- func (s PostService) DisableReplies(ctx context.Context, id string) (*Response, error)
- func (s PostService) Downvote(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Duplicates(ctx context.Context, id string, opts *ListDuplicatePostOptions) (*Post, *Posts, *Response, error)
- func (s *PostService) Edit(ctx context.Context, id string, text string) (*Post, *Response, error)
- func (s *PostService) EnableContestMode(ctx context.Context, id string) (*Response, error)
- func (s PostService) EnableReplies(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Get(ctx context.Context, id string) (*PostAndComments, *Response, error)
- func (s *PostService) Hide(ctx context.Context, ids ...string) (*Response, error)
- func (s *PostService) LoadMoreComments(ctx context.Context, pc *PostAndComments) (*Response, error)
- func (s PostService) Lock(ctx context.Context, id string) (*Response, error)
- func (s *PostService) MarkNSFW(ctx context.Context, id string) (*Response, error)
- func (s *PostService) MarkVisited(ctx context.Context, ids ...string) (*Response, error)
- func (s *PostService) PinToProfile(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Random(ctx context.Context) (*PostAndComments, *Response, error)
- func (s *PostService) RandomFromSubreddits(ctx context.Context, subreddits ...string) (*PostAndComments, *Response, error)
- func (s *PostService) RandomFromSubscriptions(ctx context.Context) (*PostAndComments, *Response, error)
- func (s PostService) RemoveVote(ctx context.Context, id string) (*Response, error)
- func (s PostService) Report(ctx context.Context, id string, reason string) (*Response, error)
- func (s PostService) Save(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortAMA(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortBest(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortControversial(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortLive(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortNew(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortOld(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortRandom(ctx context.Context, id string) (*Response, error)
- func (s *PostService) SetSuggestedSortTop(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Spoiler(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Sticky(ctx context.Context, id string, bottom bool) (*Response, error)
- func (s *PostService) SubmitLink(ctx context.Context, opts SubmitLinkOptions) (*Submitted, *Response, error)
- func (s *PostService) SubmitText(ctx context.Context, opts SubmitTextOptions) (*Submitted, *Response, error)
- func (s *PostService) Unhide(ctx context.Context, ids ...string) (*Response, error)
- func (s PostService) Unlock(ctx context.Context, id string) (*Response, error)
- func (s *PostService) UnmarkNSFW(ctx context.Context, id string) (*Response, error)
- func (s *PostService) UnpinFromProfile(ctx context.Context, id string) (*Response, error)
- func (s PostService) Unsave(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Unspoiler(ctx context.Context, id string) (*Response, error)
- func (s *PostService) Unsticky(ctx context.Context, id string) (*Response, error)
- func (s PostService) Upvote(ctx context.Context, id string) (*Response, error)
- type Posts
- type Relationship
- type Relationships
- type Replies
- type RequestCompletionCallback
- type Response
- type SendMessageRequest
- type Settings
- type StreamOpt
- type StreamService
- type SubmitLinkOptions
- type SubmitTextOptions
- type Submitted
- type Subreddit
- type SubredditKarma
- type SubredditNames
- type SubredditService
- func (s *SubredditService) Approved(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) Banned(ctx context.Context, subreddit string, opts *ListOptions) (*Bans, *Response, error)
- func (s *SubredditService) Contributors(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
- func (s *SubredditService) ControversialPosts(ctx context.Context, subreddit string, opts *ListPostOptions) (*Posts, *Response, error)
- func (s *SubredditService) Default(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) Favorite(ctx context.Context, subreddit string) (*Response, error)
- func (s *SubredditService) Get(ctx context.Context, name string) (*Subreddit, *Response, error)
- func (s *SubredditService) GetSticky1(ctx context.Context, subreddit string) (*PostAndComments, *Response, error)
- func (s *SubredditService) GetSticky2(ctx context.Context, subreddit string) (*PostAndComments, *Response, error)
- func (s *SubredditService) Gold(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) HotPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
- func (s *SubredditService) Moderated(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) Moderators(ctx context.Context, subreddit string) ([]*Moderator, *Response, error)
- func (s *SubredditService) Muted(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
- func (s *SubredditService) New(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) NewPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
- func (s *SubredditService) Popular(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) Random(ctx context.Context) (*Subreddit, *Response, error)
- func (s *SubredditService) RandomNSFW(ctx context.Context) (*Subreddit, *Response, error)
- func (s *SubredditService) RisingPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
- func (s *SubredditService) Search(ctx context.Context, query string, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) SearchNames(ctx context.Context, query string) ([]string, *Response, error)
- func (s *SubredditService) SearchPosts(ctx context.Context, query string, subreddit string, ...) (*Posts, *Response, error)
- func (s *SubredditService) SubmissionText(ctx context.Context, name string) (string, *Response, error)
- func (s *SubredditService) Subscribe(ctx context.Context, subreddits ...string) (*Response, error)
- func (s *SubredditService) SubscribeByID(ctx context.Context, ids ...string) (*Response, error)
- func (s *SubredditService) Subscribed(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
- func (s *SubredditService) TopPosts(ctx context.Context, subreddit string, opts *ListPostOptions) (*Posts, *Response, error)
- func (s *SubredditService) Unfavorite(ctx context.Context, subreddit string) (*Response, error)
- func (s *SubredditService) Unsubscribe(ctx context.Context, subreddits ...string) (*Response, error)
- func (s *SubredditService) UnsubscribeByID(ctx context.Context, ids ...string) (*Response, error)
- func (s *SubredditService) WikiBanned(ctx context.Context, subreddit string, opts *ListOptions) (*Bans, *Response, error)
- func (s *SubredditService) WikiContributors(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
- type Subreddits
- type Timestamp
- type Trophy
- type User
- type UserService
- func (s *UserService) Block(ctx context.Context, username string) (*Blocked, *Response, error)
- func (s *UserService) BlockByID(ctx context.Context, id string) (*Blocked, *Response, error)
- func (s *UserService) Comments(ctx context.Context, opts *ListUserOverviewOptions) (*Comments, *Response, error)
- func (s *UserService) CommentsOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Comments, *Response, error)
- func (s *UserService) Downvoted(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) DownvotedOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) Friend(ctx context.Context, username string) (*Relationship, *Response, error)
- func (s *UserService) Get(ctx context.Context, username string) (*User, *Response, error)
- func (s *UserService) GetFriendship(ctx context.Context, username string) (*Relationship, *Response, error)
- func (s *UserService) GetMultipleByID(ctx context.Context, ids ...string) (map[string]*UserSummary, *Response, error)
- func (s *UserService) Gilded(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) Hidden(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) New(ctx context.Context, opts *ListUserOverviewOptions) (*Subreddits, *Response, error)
- func (s *UserService) Overview(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
- func (s *UserService) OverviewOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
- func (s *UserService) Popular(ctx context.Context, opts *ListOptions) (*Subreddits, *Response, error)
- func (s *UserService) Posts(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) PostsOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) Saved(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
- func (s *UserService) Search(ctx context.Context, query string, opts *ListOptions) (*Users, *Response, error)
- func (s *UserService) Trophies(ctx context.Context) ([]Trophy, *Response, error)
- func (s *UserService) TrophiesOf(ctx context.Context, username string) ([]Trophy, *Response, error)
- func (s *UserService) Unblock(ctx context.Context, username string) (*Response, error)
- func (s *UserService) UnblockByID(ctx context.Context, id string) (*Response, error)
- func (s *UserService) Unfriend(ctx context.Context, username string) (*Response, error)
- func (s *UserService) Upvoted(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) UpvotedOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
- func (s *UserService) UsernameAvailable(ctx context.Context, username string) (bool, *Response, error)
- type UserSummary
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. Reddit also sometimes sends errors with 200 codes; we check for those too.
func DoRequestWithClient ¶
func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
DoRequestWithClient submits an HTTP request using the specified client.
func FromEnv ¶
FromEnv configures the client with values from environment variables.
Supported environment variables: GO_REDDIT_CLIENT_ID to set the client's id. GO_REDDIT_CLIENT_SECRET to set the client's secret. GO_REDDIT_CLIENT_USERNAME to set the client's username. GO_REDDIT_CLIENT_PASSWORD to set the client's password.
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func StreamDiscardInitial ¶
func StreamDiscardInitial(c *streamConfig)
StreamDiscardInitial will discard data from the first fetch for the stream.
Types ¶
type APIError ¶
APIError is an error coming from Reddit.
func (*APIError) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService handles communication with the account related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_account
func (*AccountService) AddTrusted ¶
AddTrusted adds a user to your trusted users. This is not visible in the Reddit API docs.
func (*AccountService) Blocked ¶
func (s *AccountService) Blocked(ctx context.Context) ([]Relationship, *Response, error)
Blocked returns a list of your blocked users.
func (*AccountService) Friends ¶
func (s *AccountService) Friends(ctx context.Context) ([]Relationship, *Response, error)
Friends returns a list of your friends.
func (*AccountService) Karma ¶
func (s *AccountService) Karma(ctx context.Context) ([]SubredditKarma, *Response, error)
Karma returns a breakdown of your karma per subreddit.
func (*AccountService) Messaging ¶
func (s *AccountService) Messaging(ctx context.Context) ([]Relationship, []Relationship, *Response, error)
Messaging returns blocked users and trusted users, respectively.
func (*AccountService) RemoveTrusted ¶
RemoveTrusted removes a user from your trusted users. This is not visible in the Reddit API docs.
func (*AccountService) Trusted ¶
func (s *AccountService) Trusted(ctx context.Context) ([]Relationship, *Response, error)
Trusted returns a list of your trusted users.
func (*AccountService) UpdateSettings ¶
func (s *AccountService) UpdateSettings(ctx context.Context, settings *Settings) (*Settings, *Response, error)
UpdateSettings updates your account settings and returns the modified version.
type Ban ¶
type Ban struct { *Relationship // nil means the ban is permanent DaysLeft *int `json:"days_left"` Note string `json:"note,omitempty"` }
Ban represents a banned relationship.
type BanConfig ¶
type BanConfig struct { Reason string `url:"reason,omitempty"` // Not visible to the user being banned. ModNote string `url:"note,omitempty"` // How long the ban will last. 0-999. Leave nil for permanent. Days *int `url:"duration,omitempty"` // Note to include in the ban message to the user. Message string `url:"ban_message,omitempty"` }
BanConfig configures the ban of the user being banned.
type Bans ¶
type Bans struct { Bans []*Ban `json:"bans"` After string `json:"after"` Before string `json:"before"` }
Bans is a listing of bans.
type Blocked ¶
type Blocked struct { Blocked string `json:"name,omitempty"` BlockedID string `json:"id,omitempty"` Created *Timestamp `json:"date,omitempty"` }
Blocked represents a blocked relationship.
type Client ¶
type Client struct { BaseURL *url.URL TokenURL *url.URL ID string Secret string Username string Password string Account *AccountService Collection *CollectionService Comment *CommentService Emoji *EmojiService Flair *FlairService Gold *GoldService Listings *ListingsService Message *MessageService Moderation *ModerationService Multi *MultiService Post *PostService Stream *StreamService Subreddit *SubredditService User *UserService // contains filtered or unexported fields }
Client manages communication with the Reddit API.
func NewClient ¶
NewClient returns a new Reddit API client. If a nil httpClient is provided, a new http.Client will be used.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. The path is the relative URL which will be resolves to the BaseURL of the Client. It should always be specified without a preceding slash.
func (*Client) NewRequestWithForm ¶
func (c *Client) NewRequestWithForm(method string, path string, form url.Values) (*http.Request, error)
NewRequestWithForm creates an API request with form data. The path is the relative URL which will be resolves to the BaseURL of the Client. It should always be specified without a preceding slash.
func (*Client) OnRequestCompleted ¶
func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
OnRequestCompleted sets the client's request completion callback.
type Collection ¶
type Collection struct { ID string `json:"collection_id,omitempty"` Created *Timestamp `json:"created_at_utc,omitempty"` Updated *Timestamp `json:"last_update_utc,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Permalink string `json:"permalink,omitempty"` Layout string `json:"display_layout,omitempty"` SubredditID string `json:"subreddit_id,omitempty"` Author string `json:"author_name,omitempty"` AuthorID string `json:"author_id,omitempty"` // Post at the top of the collection. // This does not appear when getting a list of collections. PrimaryPostID string `json:"primary_link_id,omitempty"` PostIDs []string `json:"link_ids,omitempty"` }
Collection is a mod curated group of posts within a subreddit.
type CollectionCreateRequest ¶
type CollectionCreateRequest struct { Title string `url:"title"` Description string `url:"description,omitempty"` SubredditID string `url:"sr_fullname"` // One of: TIMELINE, GALLERY. Layout string `url:"display_layout,omitempty"` }
CollectionCreateRequest represents a request to create a collection.
type CollectionService ¶
type CollectionService struct {
// contains filtered or unexported fields
}
CollectionService handles communication with the collection related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_collections
func (*CollectionService) AddPost ¶
func (s *CollectionService) AddPost(ctx context.Context, postID, collectionID string) (*Response, error)
AddPost adds a post (via its full ID) to a collection (via its id).
func (*CollectionService) Create ¶
func (s *CollectionService) Create(ctx context.Context, createRequest *CollectionCreateRequest) (*Collection, *Response, error)
Create creates a collection.
func (*CollectionService) FromSubreddit ¶
func (s *CollectionService) FromSubreddit(ctx context.Context, id string) ([]*Collection, *Response, error)
FromSubreddit gets all collections in the subreddit.
func (*CollectionService) Get ¶
func (s *CollectionService) Get(ctx context.Context, id string) (*Collection, *Response, error)
Get gets a collection by its ID.
func (*CollectionService) RemovePost ¶
func (s *CollectionService) RemovePost(ctx context.Context, postID, collectionID string) (*Response, error)
RemovePost removes a post (via its full ID) from a collection (via its id).
func (*CollectionService) ReorderPosts ¶
func (s *CollectionService) ReorderPosts(ctx context.Context, collectionID string, postIDs ...string) (*Response, error)
ReorderPosts reorders posts in a collection.
func (*CollectionService) UpdateDescription ¶
func (s *CollectionService) UpdateDescription(ctx context.Context, id string, description string) (*Response, error)
UpdateDescription updates a collection's description.
func (*CollectionService) UpdateLayoutGallery ¶
UpdateLayoutGallery updates a collection's layout to the gallery format.
func (*CollectionService) UpdateLayoutTimeline ¶
UpdateLayoutTimeline updates a collection's layout to the timeline format.
func (*CollectionService) UpdateTitle ¶
func (s *CollectionService) UpdateTitle(ctx context.Context, id string, title string) (*Response, error)
UpdateTitle updates a collection's title.
type Comment ¶
type Comment struct { ID string `json:"id,omitempty"` FullID string `json:"name,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` Edited *Timestamp `json:"edited,omitempty"` ParentID string `json:"parent_id,omitempty"` Permalink string `json:"permalink,omitempty"` Body string `json:"body,omitempty"` Author string `json:"author,omitempty"` AuthorID string `json:"author_fullname,omitempty"` AuthorFlairText string `json:"author_flair_text,omitempty"` AuthorFlairID string `json:"author_flair_template_id,omitempty"` SubredditName string `json:"subreddit,omitempty"` SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"` SubredditID string `json:"subreddit_id,omitempty"` // Indicates if you've upvote/downvoted (true/false). // If neither, it will be nil. Likes *bool `json:"likes"` Score int `json:"score"` Controversiality int `json:"controversiality"` PostID string `json:"link_id,omitempty"` // This doesn't appear consistently. PostTitle string `json:"link_title,omitempty"` // This doesn't appear consistently. PostPermalink string `json:"link_permalink,omitempty"` // This doesn't appear consistently. PostAuthor string `json:"link_author,omitempty"` // This doesn't appear consistently. PostNumComments *int `json:"num_comments,omitempty"` IsSubmitter bool `json:"is_submitter"` ScoreHidden bool `json:"score_hidden"` Saved bool `json:"saved"` Stickied bool `json:"stickied"` Locked bool `json:"locked"` CanGild bool `json:"can_gild"` NSFW bool `json:"over_18"` Replies Replies `json:"replies"` }
Comment is a comment posted by a user.
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
CommentService handles communication with the comment related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments
func (CommentService) DisableReplies ¶
DisableReplies dsables inbox replies for one of your posts or comments.
func (*CommentService) Edit ¶
func (s *CommentService) Edit(ctx context.Context, id string, text string) (*Comment, *Response, error)
Edit edits a comment.
func (CommentService) EnableReplies ¶
EnableReplies enables inbox replies for one of your posts or comments.
func (*CommentService) LoadMoreReplies ¶
LoadMoreReplies retrieves more replies that were left out when initially fetching the comment.
func (CommentService) Lock ¶
Lock locks a post or comment, preventing it from receiving new comments.
func (CommentService) RemoveVote ¶
RemoveVote removes your vote on a post or a comment.
func (CommentService) Report ¶
Report reports a post or comment. The reason must not be longer than 100 characters.
func (*CommentService) Submit ¶
func (s *CommentService) Submit(ctx context.Context, parentID string, text string) (*Comment, *Response, error)
Submit submits a comment as a reply to a post, comment, or message. parentID is the full ID of the thing being replied to.
func (CommentService) Unlock ¶
Unlock unlocks a post or comment, allowing it to receive new comments.
type Comments ¶
type Comments struct { Comments []*Comment `json:"comments"` After string `json:"after"` Before string `json:"before"` }
Comments is a list of comments
type Credentials ¶
Credentials used to authenticate to make requests to the Reddit API.
type Emoji ¶
type Emoji struct { Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` UserFlairAllowed bool `json:"user_flair_allowed,omitempty"` PostFlairAllowed bool `json:"post_flair_allowed,omitempty"` ModFlairOnly bool `json:"mod_flair_only,omitempty"` // ID of the user who created this emoji. CreatedBy string `json:"created_by,omitempty"` }
Emoji is a graphic element you can include in a post flair or user flair.
type EmojiCreateOrUpdateRequest ¶
type EmojiCreateOrUpdateRequest struct { Name string `url:"name"` UserFlairAllowed *bool `url:"user_flair_allowed,omitempty"` PostFlairAllowed *bool `url:"post_flair_allowed,omitempty"` ModFlairOnly *bool `url:"mod_flair_only,omitempty"` }
EmojiCreateOrUpdateRequest represents a request to create/update an emoji.
type EmojiService ¶
type EmojiService struct {
// contains filtered or unexported fields
}
EmojiService handles communication with the emoji related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_emoji
func (*EmojiService) Delete ¶
func (s *EmojiService) Delete(ctx context.Context, subreddit string, emoji string) (*Response, error)
Delete deletes the emoji from the subreddit.
func (*EmojiService) DisableCustomSize ¶
DisableCustomSize disables the custom emoji size in the subreddit.
func (*EmojiService) Get ¶
func (s *EmojiService) Get(ctx context.Context, subreddit string) ([]*Emoji, []*Emoji, *Response, error)
Get returns the default set of Reddit emojis, and those of the subreddit, respectively.
func (*EmojiService) SetSize ¶
func (s *EmojiService) SetSize(ctx context.Context, subreddit string, height, width int) (*Response, error)
SetSize sets the custom emoji size in the subreddit. Both height and width must be between 1 and 40 (inclusive).
func (*EmojiService) Update ¶
func (s *EmojiService) Update(ctx context.Context, subreddit string, updateRequest *EmojiCreateOrUpdateRequest) (*Response, error)
Update updates an emoji on the subreddit.
func (*EmojiService) Upload ¶
func (s *EmojiService) Upload(ctx context.Context, subreddit string, createRequest *EmojiCreateOrUpdateRequest, imagePath string) (*Response, error)
Upload uploads an emoji to the subreddit.
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response `json:"-"` // Error message Message string `json:"message"` }
An ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Flair ¶
type Flair struct { ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` Text string `json:"text,omitempty"` Color string `json:"text_color,omitempty"` BackgroundColor string `json:"background_color,omitempty"` CSSClass string `json:"css_class,omitempty"` Editable bool `json:"text_editable"` ModOnly bool `json:"mod_only"` }
Flair is a tag that can be attached to a user or a post.
type FlairService ¶
type FlairService struct {
// contains filtered or unexported fields
}
FlairService handles communication with the flair related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_flair
func (*FlairService) GetPostFlairs ¶
func (s *FlairService) GetPostFlairs(ctx context.Context, subreddit string) ([]*Flair, *Response, error)
GetPostFlairs returns the post flairs from the subreddit.
func (*FlairService) GetUserFlairs ¶
func (s *FlairService) GetUserFlairs(ctx context.Context, subreddit string) ([]*Flair, *Response, error)
GetUserFlairs returns the user flairs from the subreddit.
func (*FlairService) ListUserFlairs ¶
func (s *FlairService) ListUserFlairs(ctx context.Context, subreddit string) ([]*FlairSummary, *Response, error)
ListUserFlairs returns all flairs of individual users in the subreddit.
type FlairSummary ¶
type FlairSummary struct { User string `json:"user,omitempty"` Text string `json:"flair_text,omitempty"` CSSClass string `json:"flair_css_class,omitempty"` }
FlairSummary is a condensed version of Flair.
type GoldService ¶
type GoldService struct {
// contains filtered or unexported fields
}
GoldService handles communication with the gold related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_gold
type JSONErrorResponse ¶
type JSONErrorResponse struct { // HTTP response that caused this error. Response *http.Response `json:"-"` JSON struct { Errors []APIError `json:"errors,omitempty"` } `json:"json"` }
JSONErrorResponse is an error response that sometimes gets returned with a 200 code.
func (*JSONErrorResponse) Error ¶
func (r *JSONErrorResponse) Error() string
type ListDuplicatePostOptions ¶
type ListDuplicatePostOptions struct { ListOptions // If empty, it'll search for duplicates in all subreddits. Subreddit string `url:"sr,omitempty"` // One of: num_comments, new. Sort string `url:"sort,omitempty"` // If true, the search will only return duplicates that are // crossposts of the original post. CrosspostsOnly bool `url:"crossposts_only,omitempty"` }
ListDuplicatePostOptions defines possible options used when getting duplicates of a post, i.e. other submissions of the same URL.
type ListModActionOptions ¶
type ListModActionOptions struct { // The max for the limit parameter here is 500. ListOptions // If empty, the search will return all action types. // One of: banuser, unbanuser, spamlink, removelink, approvelink, spamcomment, removecomment, // approvecomment, addmoderator, showcomment, invitemoderator, uninvitemoderator, acceptmoderatorinvite, // removemoderator, addcontributor, removecontributor, editsettings, editflair, distinguish, marknsfw, // wikibanned, wikicontributor, wikiunbanned, wikipagelisted, removewikicontributor, wikirevise, // wikipermlevel, ignorereports, unignorereports, setpermissions, setsuggestedsort, sticky, unsticky, // setcontestmode, unsetcontestmode, lock, unlock, muteuser, unmuteuser, createrule, editrule, // reorderrules, deleterule, spoiler, unspoiler, modmail_enrollment, community_styling, community_widgets, // markoriginalcontent, collections, events, hidden_award, add_community_topics, remove_community_topics, // create_scheduled_post, edit_scheduled_post, delete_scheduled_post, submit_scheduled_post, // edit_post_requirements, invitesubscriber, submit_content_rating_survey. Type string `url:"type,omitempty"` // If provided, only return the actions of this moderator. Moderator string `url:"mod,omitempty"` }
ListModActionOptions defines possible options used when getting moderation actions in a subreddit.
type ListOptions ¶
type ListOptions struct { // Maximum number of items to be returned. // Generally, the default is 25 and max is 100. Limit int `url:"limit,omitempty"` // The full ID of an item in the listing to use // as the anchor point of the list. Only items // appearing after it will be returned. After string `url:"after,omitempty"` // The full ID of an item in the listing to use // as the anchor point of the list. Only items // appearing before it will be returned. Before string `url:"before,omitempty"` }
ListOptions specifies the optional parameters to various API calls that return a listing.
type ListPostOptions ¶
type ListPostOptions struct { ListOptions // One of: hour, day, week, month, year, all. Time string `url:"t,omitempty"` }
ListPostOptions defines possible options used when getting posts from a subreddit.
type ListPostSearchOptions ¶
type ListPostSearchOptions struct { ListPostOptions // One of: relevance, hot, top, new, comments. Sort string `url:"sort,omitempty"` }
ListPostSearchOptions defines possible options used when searching for posts within a subreddit.
type ListSubredditOptions ¶
type ListSubredditOptions struct { ListOptions // One of: relevance, activity. Sort string `url:"sort,omitempty"` }
ListSubredditOptions defines possible options used when searching for subreddits.
type ListUserOverviewOptions ¶
type ListUserOverviewOptions struct { ListOptions // One of: hot, new, top, controversial. Sort string `url:"sort,omitempty"` // One of: hour, day, week, month, year, all. Time string `url:"t,omitempty"` }
ListUserOverviewOptions defines possible options used when getting a user's post and/or comments.
type ListingsService ¶
type ListingsService struct {
// contains filtered or unexported fields
}
ListingsService handles communication with the listing related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_listings
type Message ¶
type Message struct { ID string `json:"id"` FullID string `json:"name"` Created *Timestamp `json:"created_utc"` Subject string `json:"subject"` Text string `json:"body"` ParentID string `json:"parent_id"` Author string `json:"author"` To string `json:"dest"` IsComment bool `json:"was_comment"` }
Message is a message.
type MessageService ¶
type MessageService struct {
// contains filtered or unexported fields
}
MessageService handles communication with the message related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_messages
func (*MessageService) Block ¶
Block blocks the author of a thing via the thing's full ID. The thing can be a post, comment or message.
func (*MessageService) Inbox ¶
func (s *MessageService) Inbox(ctx context.Context, opts *ListOptions) (*Messages, *Messages, *Response, error)
Inbox returns comments and messages that appear in your inbox, respectively.
func (*MessageService) InboxUnread ¶
func (s *MessageService) InboxUnread(ctx context.Context, opts *ListOptions) (*Messages, *Messages, *Response, error)
InboxUnread returns unread comments and messages that appear in your inbox, respectively.
func (*MessageService) ReadAll ¶
func (s *MessageService) ReadAll(ctx context.Context) (*Response, error)
ReadAll marks all messages/comments as read. It queues up the task on Reddit's end. A successful response returns 202 to acknowledge acceptance of the request. This endpoint is heavily rate limited.
func (*MessageService) Send ¶
func (s *MessageService) Send(ctx context.Context, sendRequest *SendMessageRequest) (*Response, error)
Send sends a message.
func (*MessageService) Sent ¶
func (s *MessageService) Sent(ctx context.Context, opts *ListOptions) (*Messages, *Response, error)
Sent returns messages that you've sent.
func (*MessageService) Uncollapse ¶
Uncollapse uncollapses messages.
type Messages ¶
type Messages struct { Messages []*Message `json:"messages"` After string `json:"after"` Before string `json:"before"` }
Messages is a list of messages.
type ModAction ¶
type ModAction struct { ID string `json:"id,omitempty"` Action string `json:"action,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` Moderator string `json:"mod,omitempty"` // Not the full ID, just the ID36. ModeratorID string `json:"mod_id36,omitempty"` // The author of whatever the action was produced on, e.g. a user, post, comment, etc. TargetAuthor string `json:"target_author,omitempty"` // This is the full ID of whatever the target was. TargetID string `json:"target_fullname,omitempty"` TargetTitle string `json:"target_title,omitempty"` TargetPermalink string `json:"target_permalink,omitempty"` TargetBody string `json:"target_body,omitempty"` Subreddit string `json:"subreddit,omitempty"` // Not the full ID, just the ID36. SubredditID string `json:"sr_id36,omitempty"` }
ModAction is an action executed by a moderator of a subreddit, such as inviting another user to be a mod, or setting permissions.
type ModActions ¶
type ModActions struct { ModActions []*ModAction `json:"moderator_actions"` After string `json:"after"` Before string `json:"before"` }
ModActions is a list of moderator actions.
type ModPermissions ¶
type ModPermissions struct { All bool `permission:"all"` Access bool `permission:"access"` ChatConfig bool `permission:"chat_config"` ChatOperator bool `permission:"chat_operator"` Config bool `permission:"config"` Flair bool `permission:"flair"` Mail bool `permission:"mail"` Posts bool `permission:"posts"` Wiki bool `permission:"wiki"` }
ModPermissions are the different permissions moderators have or don't have on a subreddit. Read about them here: https://mods.reddithelp.com/hc/en-us/articles/360009381491-User-Management-moderators-and-permissions
func (*ModPermissions) String ¶
func (p *ModPermissions) String() (s string)
type ModerationService ¶
type ModerationService struct {
// contains filtered or unexported fields
}
ModerationService handles communication with the moderation related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_moderation
func (*ModerationService) AcceptInvite ¶
AcceptInvite accepts a pending invite to moderate the specified subreddit.
func (*ModerationService) ApproveUser ¶
func (s *ModerationService) ApproveUser(ctx context.Context, subreddit string, username string) (*Response, error)
ApproveUser adds a user as an approved user to the subreddit.
func (*ModerationService) ApproveUserWiki ¶
func (s *ModerationService) ApproveUserWiki(ctx context.Context, subreddit string, username string) (*Response, error)
ApproveUserWiki adds a user as an approved wiki contributor in the subreddit.
func (*ModerationService) Ban ¶
func (s *ModerationService) Ban(ctx context.Context, subreddit string, username string, config *BanConfig) (*Response, error)
Ban a user from the subreddit.
func (*ModerationService) BanWiki ¶
func (s *ModerationService) BanWiki(ctx context.Context, subreddit string, username string, config *BanConfig) (*Response, error)
BanWiki a user from contributing to the subreddit wiki.
func (*ModerationService) Edited ¶
func (s *ModerationService) Edited(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Comments, *Response, error)
Edited gets posts and comments that have been edited recently.
func (*ModerationService) GetActions ¶
func (s *ModerationService) GetActions(ctx context.Context, subreddit string, opts *ListModActionOptions) (*ModActions, *Response, error)
GetActions gets a list of moderator actions on a subreddit.
func (*ModerationService) IgnoreReports ¶
IgnoreReports prevents reports on a post or comment from causing notifications.
func (*ModerationService) Invite ¶
func (s *ModerationService) Invite(ctx context.Context, subreddit string, username string, permissions *ModPermissions) (*Response, error)
Invite a user to become a moderator of the subreddit. If permissions is nil, all permissions will be granted.
func (*ModerationService) Leave ¶
Leave abdicates your moderator status in a subreddit via its full ID.
func (*ModerationService) LeaveContributor ¶
func (s *ModerationService) LeaveContributor(ctx context.Context, subredditID string) (*Response, error)
LeaveContributor abdicates your approved user status in a subreddit via its full ID.
func (*ModerationService) Mute ¶
func (s *ModerationService) Mute(ctx context.Context, subreddit string, username string) (*Response, error)
Mute a user in the subreddit.
func (*ModerationService) Remove ¶
Remove removes a post, comment or modmail message via its full ID.
func (*ModerationService) RemoveSpam ¶
RemoveSpam removes a post, comment or modmail message via its full ID and marks it as spam.
func (*ModerationService) SetPermissions ¶
func (s *ModerationService) SetPermissions(ctx context.Context, subreddit string, username string, permissions *ModPermissions) (*Response, error)
SetPermissions sets the mod permissions for the user in the subreddit. If permissions is nil, all permissions will be granted.
func (*ModerationService) UnapproveUser ¶
func (s *ModerationService) UnapproveUser(ctx context.Context, subreddit string, username string) (*Response, error)
UnapproveUser removes a user as an approved user to the subreddit.
func (*ModerationService) UnapproveUserWiki ¶
func (s *ModerationService) UnapproveUserWiki(ctx context.Context, subreddit string, username string) (*Response, error)
UnapproveUserWiki removes a user as an approved wiki contributor in the subreddit.
func (*ModerationService) Unban ¶
func (s *ModerationService) Unban(ctx context.Context, subreddit string, username string) (*Response, error)
Unban a user from the subreddit.
func (*ModerationService) UnbanWiki ¶
func (s *ModerationService) UnbanWiki(ctx context.Context, subreddit string, username string) (*Response, error)
UnbanWiki a user from contributing to the subreddit wiki.
func (*ModerationService) UnignoreReports ¶
UnignoreReports allows reports on a post or comment to cause notifications.
type Moderator ¶
type Moderator struct { *Relationship Permissions []string `json:"mod_permissions"` }
Moderator is a user who moderates a subreddit.
type More ¶
type More struct { ID string `json:"id"` FullID string `json:"name"` ParentID string `json:"parent_id"` // Total number of replies to the parent + replies to those replies (recursively). Count int `json:"count"` // Number of comment nodes from the parent down to the furthest comment node. Depth int `json:"depth"` Children []string `json:"children"` }
More holds information used to retrieve additional comments omitted from a base comment tree.
type Multi ¶
type Multi struct { Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` // Format: user/{username}/m/{multiname} Path string `json:"path,omitempty"` Description string `json:"description_md,omitempty"` Subreddits SubredditNames `json:"subreddits"` CopiedFrom *string `json:"copied_from"` Owner string `json:"owner,omitempty"` OwnerID string `json:"owner_id,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` NumberOfSubscribers int `json:"num_subscribers"` Visibility string `json:"visibility,omitempty"` Subscribed bool `json:"is_subscriber"` Favorite bool `json:"is_favorited"` CanEdit bool `json:"can_edit"` NSFW bool `json:"over_18"` }
Multi is a multireddit, i.e. a customizable group of subreddits. Users can create multis for custom navigation, instead of browsing one subreddit or all subreddits at a time.
type MultiCopyRequest ¶
type MultiCopyRequest struct { FromPath string `url:"from"` ToPath string `url:"to"` // Raw markdown text. Description string `url:"description_md,omitempty"` // No longer than 50 characters. DisplayName string `url:"display_name,omitempty"` }
MultiCopyRequest represents a request to copy a multireddit.
type MultiCreateOrUpdateRequest ¶
type MultiCreateOrUpdateRequest struct { // For updates, this is the display name, i.e. the header of the multi. // Not part of the path necessarily. Name string `json:"display_name,omitempty"` Description string `json:"description_md,omitempty"` Subreddits SubredditNames `json:"subreddits,omitempty"` // One of: private, public, hidden. Visibility string `json:"visibility,omitempty"` }
MultiCreateOrUpdateRequest represents a request to create/update a multireddit.
func (*MultiCreateOrUpdateRequest) Form ¶
func (r *MultiCreateOrUpdateRequest) Form() url.Values
Form parameterizes the fields and returns the form.
type MultiService ¶
type MultiService struct {
// contains filtered or unexported fields
}
MultiService handles communication with the multireddit related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api#section_multis
func (*MultiService) AddSubreddit ¶
func (s *MultiService) AddSubreddit(ctx context.Context, multiPath string, subreddit string) (*Response, error)
AddSubreddit adds a subreddit to a multireddit.
func (*MultiService) Copy ¶
func (s *MultiService) Copy(ctx context.Context, copyRequest *MultiCopyRequest) (*Multi, *Response, error)
Copy copies a multireddit.
func (*MultiService) Create ¶
func (s *MultiService) Create(ctx context.Context, createRequest *MultiCreateOrUpdateRequest) (*Multi, *Response, error)
Create creates a multireddit.
func (*MultiService) DeleteSubreddit ¶
func (s *MultiService) DeleteSubreddit(ctx context.Context, multiPath string, subreddit string) (*Response, error)
DeleteSubreddit removes a subreddit from a multireddit.
func (*MultiService) GetDescription ¶
func (s *MultiService) GetDescription(ctx context.Context, multiPath string) (string, *Response, error)
GetDescription gets a multireddit's description.
func (*MultiService) Of ¶
Of returns the user's public multireddits. Or, if the user is you, all of your multireddits.
func (*MultiService) Update ¶
func (s *MultiService) Update(ctx context.Context, multiPath string, updateRequest *MultiCreateOrUpdateRequest) (*Multi, *Response, error)
Update updates a multireddit. If the multireddit does not exist, it will be created.
func (*MultiService) UpdateDescription ¶
func (s *MultiService) UpdateDescription(ctx context.Context, multiPath string, description string) (string, *Response, error)
UpdateDescription updates a multireddit's description.
type Opt ¶
Opt is a configuration option to initialize a client.
func WithBaseURL ¶
WithBaseURL sets the base URL for the client to make requests to.
func WithTokenURL ¶
WithTokenURL sets the url used to get access tokens.
type Post ¶
type Post struct { ID string `json:"id,omitempty"` FullID string `json:"name,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` Edited *Timestamp `json:"edited,omitempty"` Permalink string `json:"permalink,omitempty"` URL string `json:"url,omitempty"` Title string `json:"title,omitempty"` Body string `json:"selftext,omitempty"` // Indicates if you've upvote/downvoted (true/false). // If neither, it will be nil. Likes *bool `json:"likes"` Score int `json:"score"` UpvoteRatio float32 `json:"upvote_ratio"` NumberOfComments int `json:"num_comments"` SubredditName string `json:"subreddit,omitempty"` SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"` SubredditID string `json:"subreddit_id,omitempty"` Author string `json:"author,omitempty"` AuthorID string `json:"author_fullname,omitempty"` Spoiler bool `json:"spoiler"` Locked bool `json:"locked"` NSFW bool `json:"over_18"` IsSelfPost bool `json:"is_self"` Saved bool `json:"saved"` Stickied bool `json:"stickied"` }
Post is a submitted post on Reddit.
type PostAndComments ¶
type PostAndComments struct { Post *Post `json:"post"` Comments []*Comment `json:"comments"` More *More `json:"-"` }
PostAndComments is a post and its comments.
func (*PostAndComments) HasMore ¶
func (pc *PostAndComments) HasMore() bool
HasMore determines whether the post has more replies to load in its reply tree.
func (*PostAndComments) UnmarshalJSON ¶
func (pc *PostAndComments) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. When getting a sticky post, you get an array of 2 Listings The 1st one contains the single post in its children array The 2nd one contains the comments to the post
type PostService ¶
type PostService struct {
// contains filtered or unexported fields
}
PostService handles communication with the post related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments
func (*PostService) ClearSuggestedSort ¶
ClearSuggestedSort clears the suggested comment sort for the post.
func (*PostService) DisableContestMode ¶
DisableContestMode disables contest mode for the post.
func (PostService) DisableReplies ¶
DisableReplies dsables inbox replies for one of your posts or comments.
func (*PostService) Duplicates ¶
func (s *PostService) Duplicates(ctx context.Context, id string, opts *ListDuplicatePostOptions) (*Post, *Posts, *Response, error)
Duplicates returns the post with the id, and a list of its duplicates. id is the ID36 of the post, not its full id. Example: instead of t3_abc123, use abc123.
func (*PostService) EnableContestMode ¶
EnableContestMode enables contest mode for the post. Comments will be sorted randomly and regular users cannot see comment scores.
func (PostService) EnableReplies ¶
EnableReplies enables inbox replies for one of your posts or comments.
func (*PostService) Get ¶
func (s *PostService) Get(ctx context.Context, id string) (*PostAndComments, *Response, error)
Get returns a post with its comments. id is the ID36 of the post, not its full id. Example: instead of t3_abc123, use abc123.
func (*PostService) LoadMoreComments ¶
func (s *PostService) LoadMoreComments(ctx context.Context, pc *PostAndComments) (*Response, error)
LoadMoreComments retrieves more comments that were left out when initially fetching the post.
func (*PostService) MarkVisited ¶
MarkVisited marks the post(s) as visited. This method requires a subscription to Reddit premium.
func (*PostService) PinToProfile ¶
PinToProfile pins one of your posts to your profile. TODO: very inconsistent behaviour, not sure I'm ready to include this parameter yet. The pos parameter should be a number between 1-4 (inclusive), indicating the position at which the post should appear on your profile. Note: The position will be bumped upward if there's space. E.g. if you only have 1 pinned post, and you try to pin another post to position 3, it will be pinned at 2. When attempting to pin a post that's already pinned, it will return a 409 Conflict error.
func (*PostService) Random ¶
func (s *PostService) Random(ctx context.Context) (*PostAndComments, *Response, error)
Random returns a random post and its comments from all of Reddit.
func (*PostService) RandomFromSubreddits ¶
func (s *PostService) RandomFromSubreddits(ctx context.Context, subreddits ...string) (*PostAndComments, *Response, error)
RandomFromSubreddits returns a random post and its comments from the subreddits. If no subreddits are provided, Reddit runs the query against your subscriptions.
func (*PostService) RandomFromSubscriptions ¶
func (s *PostService) RandomFromSubscriptions(ctx context.Context) (*PostAndComments, *Response, error)
RandomFromSubscriptions returns a random post and its comments from your subscriptions.
func (PostService) RemoveVote ¶
RemoveVote removes your vote on a post or a comment.
func (PostService) Report ¶
Report reports a post or comment. The reason must not be longer than 100 characters.
func (*PostService) SetSuggestedSortAMA ¶
SetSuggestedSortAMA sets the suggested comment sort for the post to a Q&A styled fashion.
func (*PostService) SetSuggestedSortBest ¶
SetSuggestedSortBest sets the suggested comment sort for the post to best.
func (*PostService) SetSuggestedSortControversial ¶
func (s *PostService) SetSuggestedSortControversial(ctx context.Context, id string) (*Response, error)
SetSuggestedSortControversial sets the suggested comment sort for the post to controversial.
func (*PostService) SetSuggestedSortLive ¶
SetSuggestedSortLive sets the suggested comment sort for the post to stream new comments as they're posted. As of now, this is still in beta, so it's not a fully developed feature yet. It just sets the sort as "new" for now.
func (*PostService) SetSuggestedSortNew ¶
SetSuggestedSortNew sets the suggested comment sort for the post to new.
func (*PostService) SetSuggestedSortOld ¶
SetSuggestedSortOld sorts the comments on the posts randomly.
func (*PostService) SetSuggestedSortRandom ¶
SetSuggestedSortRandom sets the suggested comment sort for the post to random.
func (*PostService) SetSuggestedSortTop ¶
SetSuggestedSortTop sets the suggested comment sort for the post to top.
func (*PostService) Sticky ¶
Sticky stickies a post in its subreddit. When bottom is true, the post will be set as the bottom sticky (the 2nd one). If no top sticky exists, the post will become the top sticky regardless. When attempting to sticky a post that's already stickied, it will return a 409 Conflict error.
func (*PostService) SubmitLink ¶
func (s *PostService) SubmitLink(ctx context.Context, opts SubmitLinkOptions) (*Submitted, *Response, error)
SubmitLink submits a link post.
func (*PostService) SubmitText ¶
func (s *PostService) SubmitText(ctx context.Context, opts SubmitTextOptions) (*Submitted, *Response, error)
SubmitText submits a text post.
func (*PostService) UnmarkNSFW ¶
UnmarkNSFW unmarks a post as NSFW.
func (*PostService) UnpinFromProfile ¶
UnpinFromProfile unpins one of your posts from your profile.
type Posts ¶
type Posts struct { Posts []*Post `json:"posts"` After string `json:"after"` Before string `json:"before"` }
Posts is a list of posts.
type Relationship ¶
type Relationship struct { ID string `json:"rel_id,omitempty"` User string `json:"name,omitempty"` UserID string `json:"id,omitempty"` Created *Timestamp `json:"date,omitempty"` }
Relationship holds information about a relationship (friend/blocked). todo: there's also banned, wikibanned, etc.
type Relationships ¶
type Relationships struct { Relationships []*Relationship `json:"relationships"` After string `json:"after"` Before string `json:"before"` }
Relationships is a listing of relationships.
type Replies ¶
Replies holds replies to a comment. It contains both comments and "more" comments, which are entrypoints to other comments that were left out.
func (*Replies) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Replies) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type RequestCompletionCallback ¶
RequestCompletionCallback defines the type of the request callback function.
type Response ¶
Response is a PlayNetwork response. This wraps the standard http.Response returned from PlayNetwork.
type SendMessageRequest ¶
type SendMessageRequest struct { // Username, or /r/name for that subreddit's moderators. To string `url:"to"` Subject string `url:"subject"` Text string `url:"text"` // Optional. If specified, the message will look like it came from the subreddit. FromSubreddit string `url:"from_sr,omitempty"` }
SendMessageRequest represents a request to send a message.
type Settings ¶
type Settings struct { // Control whose private messages you see. // - "everyone": everyone except blocked users // - "whitelisted": only trusted users AcceptPrivateMessages *string `json:"accept_pms,omitempty"` // Allow Reddit to use your activity on Reddit to show you more relevant advertisements. ActivityRelevantAds *bool `json:"activity_relevant_ads,omitempty"` // Allow reddit to log my outbound clicks for personalization. AllowClickTracking *bool `json:"allow_clicktracking,omitempty"` // Beta test features for reddit. By enabling, you will join r/beta immediately. Beta *bool `json:"beta,omitempty"` // Show me links I've recently viewed. ShowRecentlyViewedPosts *bool `json:"clickgadget,omitempty"` CollapseReadMessages *bool `json:"collapse_read_messages,omitempty"` // Compress the post display (make them look more compact). Compress *bool `json:"compress,omitempty"` CredditAutorenew *bool `json:"creddit_autorenew,omitempty"` // One of "confidence", "top", "new", "controversial", "old", "random", "qa", "live". DefaultCommentSort *string `json:"default_comment_sort,omitempty"` // Show additional details in the domain text when available, // such as the source subreddit or the content author’s url/name. ShowDomainDetails *bool `json:"domain_details,omitempty"` SendEmailDigests *bool `json:"email_digests,omitempty"` SendMessagesAsEmails *bool `json:"email_messages,omitempty"` UnsubscribeFromAllEmails *bool `json:"email_unsubscribe_all,omitempty"` // Disable subreddits from displaying their custom themes. DisableCustomThemes *bool `json:"enable_default_themes,omitempty"` // One of "GLOBAL", "AR", "AU", "BG", "CA", "CL", "CO", "CZ", "FI", "GB", "GR", "HR", "HU", // "IE", "IN", "IS", "JP", "MX", "MY", "NZ", "PH", "PL", "PR", "PT", "RO", "RS", "SE", "SG", // "TH", "TR", "TW", "US", "US_AK", "US_AL", "US_AR", "US_AZ", "US_CA", "US_CO", "US_CT", // "US_DC", "US_DE", "US_FL", "US_GA", "US_HI", "US_IA", "US_ID", "US_IL", "US_IN", "US_KS", // "US_KY", "US_LA", "US_MA", "US_MD", "US_ME", "US_MI", "US_MN", "US_MO", "US_MS", "US_MT", // "US_NC", "US_ND", "US_NE", "US_NH", "US_NJ", "US_NM", "US_NV", "US_NY", "US_OH", "US_OK", // "US_OR", "US_PA", "US_RI", "US_SC", "US_SD", "US_TN", "US_TX", "US_UT", "US_VA", "US_VT", // "US_WA", "US_WI", "US_WV", "US_WY". Location *string `json:"geopopular,omitempty"` HideAds *bool `json:"hide_ads,omitempty"` // Don't allow search engines to index my user profile. HideFromSearchEngines *bool `json:"hide_from_robots,omitempty"` // Don’t show me posts after I’ve upvoted them, except my own. HideUpvotedPosts *bool `json:"hide_ups,omitempty"` // Don’t show me posts after I’ve downvoted them, except my own. HideDownvotedPosts *bool `json:"hide_downs,omitempty"` // Show a dagger (†) on comments voted controversial (one that's been // upvoted and downvoted significantly). HighlightControversialComments *bool `json:"highlight_controversial,omitempty"` HighlightNewComments *bool `json:"highlight_new_comments,omitempty"` // Ignore suggested sorts for specific threads/subreddits, like Q&As. IgnoreSuggestedSorts *bool `json:"ignore_suggested_sort,omitempty"` // Use new Reddit as my default experience. // Use this to SET the setting. UseNewReddit *bool `json:"in_redesign_beta,omitempty"` // Use new Reddit as my default experience. // Use this to GET the setting. UsesNewReddit *bool `json:"design_beta,omitempty"` // Label posts that are not safe for work (NSFW). LabelNSFW *bool `json:"label_nsfw,omitempty"` // A valid IETF language tag (underscore separated). Language *string `json:"lang,omitempty"` ShowOldSearchPage *bool `json:"legacy_search,omitempty"` // Send message notifications in my browser. EnableNotifications *bool `json:"live_orangereds,omitempty"` MarkMessagesAsRead *bool `json:"mark_messages_read,omitempty"` // Determine whether to show thumbnails next to posts in subreddits. // - "on": show thumbnails next to posts // - "off": do not show thumbnails next to posts // - "subreddit": show thumbnails next to posts based on the subreddit's preferences ShowThumbnails *string `json:"media,omitempty"` // Determine whether to auto-expand media in subreddits. // - "on": auto-expand media previews // - "off": do not auto-expand media previews // - "subreddit": auto-expand media previews based on the subreddit's preferences AutoExpandMedia *string `json:"media_preview,omitempty"` // Don't show me comments with a score less than this number. // Must be between -100 and 100 (inclusive). MinimumCommentScore *int `json:"min_comment_score,omitempty"` // Don't show me posts with a score less than this number. // Must be between -100 and 100 (inclusive). MinimumPostScore *int `json:"min_link_score,omitempty"` // Notify me when people say my username. EnableMentionNotifications *bool `json:"monitor_mentions,omitempty"` // Opens link in a new window/tab. OpenLinksInNewWindow *bool `json:"newwindow,omitempty"` DarkMode *bool `json:"nightmode,omitempty"` DisableProfanity *bool `json:"no_profanity,omitempty"` // Display this many comments by default. // Must be between 1 and 500 (inclusive). NumberOfComments *int `json:"num_comments,omitempty,omitempty"` // Display this many posts by default. // Must be between 1 and 100 (inclusive). NumberOfPosts *int `json:"numsites,omitempty,omitempty"` // Show the spotlight box on the home feed. // Not sure what this is though... ShowSpotlightBox *bool `json:"organic,omitempty"` SubredditTheme *string `json:"other_theme,omitempty"` // Show content that is labeled not safe for work (NSFW). ShowNSFW *bool `json:"over_18,omitempty"` EnablePrivateRSSFeeds *bool `json:"private_feeds,omitempty"` // View user profiles on desktop using legacy mode. ProfileOptOut *bool `json:"profile_opt_out,omitempty"` // Make my upvotes and downvotes public. PublicizeVotes *bool `json:"public_votes,omitempty"` // Allow my data to be used for research purposes. AllowResearch *bool `json:"research,omitempty"` IncludeNSFWSearchResults *bool `json:"search_include_over_18,omitempty"` // Receive a message when my post gets cross-posted. ReceiveCrosspostMessages *bool `json:"send_crosspost_messages,omitempty"` // Receive welcome messages from moderators when I join a community. ReceiveWelcomeMessages *bool `json:"send_welcome_messages,omitempty"` // Show a user's flair (next to their name on a post or comment). ShowUserFlair *bool `json:"show_flair,omitempty"` // Show a post's flair. ShowPostFlair *bool `json:"show_link_flair,omitempty"` // Show how much gold you have remaining on your profile. ShowGoldExpiration *bool `json:"show_gold_expiration,omitempty"` ShowLocationBasedRecommendations *bool `json:"show_location_based_recommendations,omitempty"` ShowPromote *bool `json:"show_promote,omitempty"` ShowCustomSubredditThemes *bool `json:"show_stylesheets,omitempty"` // Show trending subreddits on the home feed. ShowTrendingSubreddits *bool `json:"show_trending,omitempty"` ShowTwitter *bool `json:"show_twitter,omitempty"` // Store whether or not you want to track posts you've visited. StoreVisits *bool `json:"store_visits,omitempty"` ThemeSelector *string `json:"theme_selector,omitempty"` // Allow Reddit to use data provided by third-parties to show you more relevant advertisements on Reddit.i AllowThirdPartyDataAdPersonalization *bool `json:"third_party_data_personalized_ads,omitempty"` // Allow personalization of advertisements using data from third-party websites. AllowThirdPartySiteDataAdPersonalization *bool `json:"third_party_site_data_personalized_ads,omitempty"` // Allow personalization of content using data from third-party websites. AllowThirdPartySiteDataContentPersonalization *bool `json:"third_party_site_data_personalized_content,omitempty"` EnableThreadedMessages *bool `json:"threaded_messages,omitempty"` EnableThreadedModmail *bool `json:"threaded_modmail,omitempty"` // Show the communities you are active in on your profile (mobile only). TopKarmaSubreddits *bool `json:"top_karma_subreddits,omitempty"` UseGlobalDefaults *bool `json:"use_global_defaults,omitempty"` EnableVideoAutoplay *bool `json:"video_autoplay,omitempty"` }
Settings are the user's account settings. Some of the fields' descriptions are taken from: https://praw.readthedocs.io/en/latest/code_overview/other/preferences.html#praw.models.Preferences.update
type StreamOpt ¶
type StreamOpt func(*streamConfig)
StreamOpt is a configuration option to configure a stream.
func StreamInterval ¶
StreamInterval sets the frequency at which data will be fetched for the stream. If the duration is 0 or less, it will not be set and the default will be used.
func StreamMaxRequests ¶
StreamMaxRequests sets a limit on the number of times data is fetched for a stream. If less than or equal to 0, it is assumed to be infinite.
type StreamService ¶
type StreamService struct {
// contains filtered or unexported fields
}
StreamService allows streaming new content from Reddit as it appears.
func (*StreamService) Posts ¶
func (s *StreamService) Posts(subreddit string, opts ...StreamOpt) (<-chan *Post, <-chan error, func())
Posts streams posts from the specified subreddit. It returns 2 channels and a function:
- a channel into which new posts will be sent
- a channel into which any errors will be sent
- a function that the client can call once to stop the streaming and close the channels
Because of the 100 post limit imposed by Reddit when fetching posts, some high-traffic streams might drop submissions between API requests, such as when streaming r/all.
type SubmitLinkOptions ¶
type SubmitLinkOptions struct { Subreddit string `url:"sr,omitempty"` Title string `url:"title,omitempty"` URL string `url:"url,omitempty"` FlairID string `url:"flair_id,omitempty"` FlairText string `url:"flair_text,omitempty"` SendReplies *bool `url:"sendreplies,omitempty"` Resubmit bool `url:"resubmit,omitempty"` NSFW bool `url:"nsfw,omitempty"` Spoiler bool `url:"spoiler,omitempty"` }
SubmitLinkOptions are options used for link posts.
type SubmitTextOptions ¶
type SubmitTextOptions struct { Subreddit string `url:"sr,omitempty"` Title string `url:"title,omitempty"` Text string `url:"text,omitempty"` FlairID string `url:"flair_id,omitempty"` FlairText string `url:"flair_text,omitempty"` SendReplies *bool `url:"sendreplies,omitempty"` NSFW bool `url:"nsfw,omitempty"` Spoiler bool `url:"spoiler,omitempty"` }
SubmitTextOptions are options used for text posts.
type Submitted ¶
type Submitted struct { ID string `json:"id,omitempty"` FullID string `json:"name,omitempty"` URL string `json:"url,omitempty"` }
Submitted is a newly submitted post on Reddit.
type Subreddit ¶
type Subreddit struct { ID string `json:"id,omitempty"` FullID string `json:"name,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` URL string `json:"url,omitempty"` Name string `json:"display_name,omitempty"` NamePrefixed string `json:"display_name_prefixed,omitempty"` Title string `json:"title,omitempty"` Description string `json:"public_description,omitempty"` Type string `json:"subreddit_type,omitempty"` SuggestedCommentSort string `json:"suggested_comment_sort,omitempty"` Subscribers int `json:"subscribers"` ActiveUserCount *int `json:"active_user_count,omitempty"` NSFW bool `json:"over18"` UserIsMod bool `json:"user_is_moderator"` Subscribed bool `json:"user_is_subscriber"` Favorite bool `json:"user_has_favorited"` }
Subreddit holds information about a subreddit
type SubredditKarma ¶
type SubredditKarma struct { Subreddit string `json:"sr"` PostKarma int `json:"link_karma"` CommentKarma int `json:"comment_karma"` }
SubredditKarma holds user karma data for the subreddit.
type SubredditNames ¶
type SubredditNames []string
SubredditNames is a list of subreddit names.
func (*SubredditNames) MarshalJSON ¶
func (n *SubredditNames) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*SubredditNames) UnmarshalJSON ¶
func (n *SubredditNames) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type SubredditService ¶
type SubredditService struct {
// contains filtered or unexported fields
}
SubredditService handles communication with the subreddit related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_subreddits
func (*SubredditService) Approved ¶
func (s *SubredditService) Approved(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Approved returns the list of subreddits you are an approved user in.
func (*SubredditService) Banned ¶
func (s *SubredditService) Banned(ctx context.Context, subreddit string, opts *ListOptions) (*Bans, *Response, error)
Banned gets banned users from the subreddit.
func (*SubredditService) Contributors ¶
func (s *SubredditService) Contributors(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
Contributors gets contributors (also known as approved users) from the subreddit.
func (*SubredditService) ControversialPosts ¶
func (s *SubredditService) ControversialPosts(ctx context.Context, subreddit string, opts *ListPostOptions) (*Posts, *Response, error)
ControversialPosts returns the most controversial posts from the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If none are defined, it returns the ones from your subscribed subreddits. To search through all, just specify "all". To search through all and filter out subreddits, provide "all-name1-name2".
func (*SubredditService) Default ¶
func (s *SubredditService) Default(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Default returns default subreddits.
func (*SubredditService) GetSticky1 ¶
func (s *SubredditService) GetSticky1(ctx context.Context, subreddit string) (*PostAndComments, *Response, error)
GetSticky1 returns the first stickied post on a subreddit (if it exists).
func (*SubredditService) GetSticky2 ¶
func (s *SubredditService) GetSticky2(ctx context.Context, subreddit string) (*PostAndComments, *Response, error)
GetSticky2 returns the second stickied post on a subreddit (if it exists).
func (*SubredditService) Gold ¶
func (s *SubredditService) Gold(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Gold returns gold subreddits (i.e. only accessible to users with gold). It seems like it returns an empty list if you don't have gold.
func (*SubredditService) HotPosts ¶
func (s *SubredditService) HotPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
HotPosts returns the hottest posts from the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If none are defined, it returns the ones from your subscribed subreddits. To search through all, just specify "all". To search through all and filter out subreddits, provide "all-name1-name2". Note: when looking for hot posts in a subreddit, it will include the stickied posts (if any) PLUS posts from the limit parameter (25 by default).
func (*SubredditService) Moderated ¶
func (s *SubredditService) Moderated(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Moderated returns the list of subreddits you are a moderator of.
func (*SubredditService) Moderators ¶
func (s *SubredditService) Moderators(ctx context.Context, subreddit string) ([]*Moderator, *Response, error)
Moderators gets the moderators of the subreddit.
func (*SubredditService) Muted ¶
func (s *SubredditService) Muted(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
Muted gets muted users from the subreddit.
func (*SubredditService) New ¶
func (s *SubredditService) New(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
New returns new subreddits.
func (*SubredditService) NewPosts ¶
func (s *SubredditService) NewPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
NewPosts returns the newest posts from the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If none are defined, it returns the ones from your subscribed subreddits. To search through all, just specify "all". To search through all and filter out subreddits, provide "all-name1-name2".
func (*SubredditService) Popular ¶
func (s *SubredditService) Popular(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Popular returns popular subreddits.
func (*SubredditService) RandomNSFW ¶
RandomNSFW returns a random NSFW subreddit.
func (*SubredditService) RisingPosts ¶
func (s *SubredditService) RisingPosts(ctx context.Context, subreddit string, opts *ListOptions) (*Posts, *Response, error)
RisingPosts returns the rising posts from the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If none are defined, it returns the ones from your subscribed subreddits. To search through all, just specify "all". To search through all and filter out subreddits, provide "all-name1-name2".
func (*SubredditService) Search ¶
func (s *SubredditService) Search(ctx context.Context, query string, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Search searches for subreddits.
func (*SubredditService) SearchNames ¶
func (s *SubredditService) SearchNames(ctx context.Context, query string) ([]string, *Response, error)
SearchNames searches for subreddits with names beginning with the query provided.
func (*SubredditService) SearchPosts ¶
func (s *SubredditService) SearchPosts(ctx context.Context, query string, subreddit string, opts *ListPostSearchOptions) (*Posts, *Response, error)
SearchPosts searches for posts in the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If no subreddit is provided, the search is run against r/all.
func (*SubredditService) SubmissionText ¶
func (s *SubredditService) SubmissionText(ctx context.Context, name string) (string, *Response, error)
SubmissionText gets the submission text for the subreddit. This text is set by the subreddit moderators and intended to be displayed on the submission form.
func (*SubredditService) SubscribeByID ¶
SubscribeByID subscribes to subreddits based on their id.
func (*SubredditService) Subscribed ¶
func (s *SubredditService) Subscribed(ctx context.Context, opts *ListSubredditOptions) (*Subreddits, *Response, error)
Subscribed returns the list of subreddits you are subscribed to.
func (*SubredditService) TopPosts ¶
func (s *SubredditService) TopPosts(ctx context.Context, subreddit string, opts *ListPostOptions) (*Posts, *Response, error)
TopPosts returns the top posts from the specified subreddit. To search through multiple, separate the names with a plus (+), e.g. "golang+test". If none are defined, it returns the ones from your subscribed subreddits. To search through all, just specify "all". To search through all and filter out subreddits, provide "all-name1-name2".
func (*SubredditService) Unfavorite ¶
Unfavorite unfavorites the subreddit.
func (*SubredditService) Unsubscribe ¶
func (s *SubredditService) Unsubscribe(ctx context.Context, subreddits ...string) (*Response, error)
Unsubscribe unsubscribes from subreddits based on their names.
func (*SubredditService) UnsubscribeByID ¶
UnsubscribeByID unsubscribes from subreddits based on their id.
func (*SubredditService) WikiBanned ¶
func (s *SubredditService) WikiBanned(ctx context.Context, subreddit string, opts *ListOptions) (*Bans, *Response, error)
WikiBanned gets banned users from the subreddit.
func (*SubredditService) WikiContributors ¶
func (s *SubredditService) WikiContributors(ctx context.Context, subreddit string, opts *ListOptions) (*Relationships, *Response, error)
WikiContributors gets contributors of the wiki from the subreddit.
type Subreddits ¶
type Subreddits struct { Subreddits []*Subreddit `json:"subreddits"` After string `json:"after"` Before string `json:"before"` }
Subreddits is a list of subreddits
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp.
func (*Timestamp) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type Trophy ¶
type Trophy struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` }
Trophy is a Reddit award.
type User ¶
type User struct { // this is not the full ID, watch out. ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` PostKarma int `json:"link_karma"` CommentKarma int `json:"comment_karma"` IsFriend bool `json:"is_friend"` IsEmployee bool `json:"is_employee"` HasVerifiedEmail bool `json:"has_verified_email"` NSFW bool `json:"over_18"` IsSuspended bool `json:"is_suspended"` }
User represents a Reddit user.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService handles communication with the user related methods of the Reddit API.
Reddit API docs: https://www.reddit.com/dev/api/#section_users
func (*UserService) Comments ¶
func (s *UserService) Comments(ctx context.Context, opts *ListUserOverviewOptions) (*Comments, *Response, error)
Comments returns a list of your comments.
func (*UserService) CommentsOf ¶
func (s *UserService) CommentsOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Comments, *Response, error)
CommentsOf returns a list of the user's comments.
func (*UserService) Downvoted ¶
func (s *UserService) Downvoted(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
Downvoted returns a list of your downvoted posts.
func (*UserService) DownvotedOf ¶
func (s *UserService) DownvotedOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
DownvotedOf returns a list of the user's downvoted posts. The user's votes must be public for this to work (unless the user is you).
func (*UserService) Friend ¶
func (s *UserService) Friend(ctx context.Context, username string) (*Relationship, *Response, error)
Friend friends a user.
func (*UserService) GetFriendship ¶
func (s *UserService) GetFriendship(ctx context.Context, username string) (*Relationship, *Response, error)
GetFriendship returns relationship details with the specified user. If the user is not your friend, it will return an error.
func (*UserService) GetMultipleByID ¶
func (s *UserService) GetMultipleByID(ctx context.Context, ids ...string) (map[string]*UserSummary, *Response, error)
GetMultipleByID returns multiple users from their full IDs. The response body is a map where the keys are the IDs (if they exist), and the value is the user.
func (*UserService) Gilded ¶
func (s *UserService) Gilded(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
Gilded returns a list of the user's gilded posts.
func (*UserService) Hidden ¶
func (s *UserService) Hidden(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
Hidden returns a list of the user's hidden posts.
func (*UserService) New ¶
func (s *UserService) New(ctx context.Context, opts *ListUserOverviewOptions) (*Subreddits, *Response, error)
New gets the most recently created user subreddits.
func (*UserService) Overview ¶
func (s *UserService) Overview(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
Overview returns a list of your posts and comments.
func (*UserService) OverviewOf ¶
func (s *UserService) OverviewOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
OverviewOf returns a list of the user's posts and comments.
func (*UserService) Popular ¶
func (s *UserService) Popular(ctx context.Context, opts *ListOptions) (*Subreddits, *Response, error)
Popular gets the user subreddits with the most activity.
func (*UserService) Posts ¶
func (s *UserService) Posts(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
Posts returns a list of your posts.
func (*UserService) PostsOf ¶
func (s *UserService) PostsOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
PostsOf returns a list of the user's posts.
func (*UserService) Saved ¶
func (s *UserService) Saved(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Comments, *Response, error)
Saved returns a list of the user's saved posts and comments.
func (*UserService) Search ¶
func (s *UserService) Search(ctx context.Context, query string, opts *ListOptions) (*Users, *Response, error)
Search searches for users. todo: maybe include the sort option? (relevance, activity)
func (*UserService) TrophiesOf ¶
TrophiesOf returns a list of the specified user's trophies.
func (*UserService) UnblockByID ¶
UnblockByID unblocks a user via their full id.
func (*UserService) Upvoted ¶
func (s *UserService) Upvoted(ctx context.Context, opts *ListUserOverviewOptions) (*Posts, *Response, error)
Upvoted returns a list of your upvoted posts.
func (*UserService) UpvotedOf ¶
func (s *UserService) UpvotedOf(ctx context.Context, username string, opts *ListUserOverviewOptions) (*Posts, *Response, error)
UpvotedOf returns a list of the user's upvoted posts. The user's votes must be public for this to work (unless the user is you).
func (*UserService) UsernameAvailable ¶
func (s *UserService) UsernameAvailable(ctx context.Context, username string) (bool, *Response, error)
UsernameAvailable checks whether a username is available for registration.
type UserSummary ¶
type UserSummary struct { Name string `json:"name,omitempty"` Created *Timestamp `json:"created_utc,omitempty"` PostKarma int `json:"link_karma"` CommentKarma int `json:"comment_karma"` NSFW bool `json:"profile_over_18"` }
UserSummary represents a Reddit user, but contains fewer pieces of information.