redditapi

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Zlib Imports: 11 Imported by: 0

README

Reddit API

A Golang Reddit API wrapper. The ones I found seemed to be geared towards watching streams instead of seeking content, so I made this.

I probably had a TODO log for this at one point but it's gone now. And it works for this application just fine.

Documentation

Index

Constants

View Source
const LISTING_PAGE_LIMIT = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Subreddit       string
	ID              string
	Name            string
	Saved           bool
	Created_utc     Timestamp
	Author_fullname string
	Score           int
	Body            string
	Parent_id       string
	Link_id         string
	Is_submitter    bool
	Removed         bool
	Edited          TSBool
	// contains filtered or unexported fields
}

func (*Comment) ClearVote

func (c *Comment) ClearVote() error

func (*Comment) Delete

func (c *Comment) Delete() error

func (*Comment) Downvote

func (c *Comment) Downvote() error

func (*Comment) Edit

func (c *Comment) Edit(text string) error

func (*Comment) Reply

func (c *Comment) Reply(text string) error

func (*Comment) Report

func (c *Comment) Report(reason string) error

func (*Comment) Save

func (c *Comment) Save() error

func (*Comment) Unsave

func (c *Comment) Unsave() error

func (*Comment) Upvote

func (c *Comment) Upvote() error

type CommentIterator

type CommentIterator struct {
	URL    string
	Reddit *Reddit
	// contains filtered or unexported fields
}

func (*CommentIterator) Buffered

func (iter *CommentIterator) Buffered() int

func (*CommentIterator) Count

func (iter *CommentIterator) Count() int

func (*CommentIterator) HasNext

func (iter *CommentIterator) HasNext() bool

func (*CommentIterator) Next

func (iter *CommentIterator) Next() (*Comment, error)

func (*CommentIterator) NextRequiresFetch

func (iter *CommentIterator) NextRequiresFetch() bool

type Multireddit

type Multireddit struct {
	Name            string
	Display_name    string
	Num_subscribers int
	Copied_from     string
	Subreddits      []struct {
		Name string
	}
	Created_utc Timestamp
	Visibility  string
	Over_18     bool
	Path        string
	Owner       string
	// contains filtered or unexported fields
}

func (*Multireddit) ListControversial

func (multi *Multireddit) ListControversial(limit int) (*SubmissionIterator, error)

func (*Multireddit) ListHot

func (multi *Multireddit) ListHot(limit int) (*SubmissionIterator, error)

func (*Multireddit) ListNew

func (multi *Multireddit) ListNew(limit int) (*SubmissionIterator, error)

func (*Multireddit) ListRising

func (multi *Multireddit) ListRising(limit int) (*SubmissionIterator, error)

func (*Multireddit) ListTop

func (multi *Multireddit) ListTop(limit int, t string) (*SubmissionIterator, error)

If t not specified, seems to default to "day"

type Reddit

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

func NewReddit

func NewReddit(userAgent string, clientId, clientSecret string) *Reddit

func (*Reddit) BySubmissionId

func (r *Reddit) BySubmissionId(s []string, limit int) (*SubmissionIterator, error)

func (*Reddit) GetRequest

func (r *Reddit) GetRequest(url string) (*http.Response, error)

func (*Reddit) IsLoggedIn

func (r *Reddit) IsLoggedIn() bool

func (*Reddit) ListControversial

func (r *Reddit) ListControversial(limit int) (*SubmissionIterator, error)

func (*Reddit) ListHot

func (r *Reddit) ListHot(limit int) (*SubmissionIterator, error)

func (*Reddit) ListNew

func (r *Reddit) ListNew(limit int) (*SubmissionIterator, error)

func (*Reddit) ListRising

func (r *Reddit) ListRising(limit int) (*SubmissionIterator, error)

func (*Reddit) ListTop

func (r *Reddit) ListTop(limit int, t string) (*SubmissionIterator, error)

If t not specified, seems to default to "day"

func (*Reddit) Login

func (r *Reddit) Login(refresh string) error

func (*Reddit) Logout

func (r *Reddit) Logout() error

func (*Reddit) Multireddit

func (red *Reddit) Multireddit(user string, name string) (*Multireddit, error)

func (*Reddit) Redditor

func (red *Reddit) Redditor(name string) (*Redditor, error)

func (*Reddit) Search

func (r *Reddit) Search(limit int, q string, sort string, t string) (*SubmissionIterator, error)

func (*Reddit) Self

func (r *Reddit) Self() *Redditor

func (*Reddit) Submission

func (red *Reddit) Submission(id string) (*Submission, error)

func (*Reddit) Subreddit

func (red *Reddit) Subreddit(id string) (*Subreddit, error)

type Redditor

type Redditor struct {
	ID                                          string
	Is_employee, Is_mod, Is_suspended, Verified bool
	Created_utc                                 Timestamp
	Name                                        string
	Icon_img                                    string
	Subreddit                                   *Subreddit
	Total_karma                                 int
	// contains filtered or unexported fields
}

func (*Redditor) Block

func (usr *Redditor) Block() error

func (*Redditor) ListComments

func (usr *Redditor) ListComments(limit int) (*CommentIterator, error)

func (*Redditor) ListDownvoted

func (usr *Redditor) ListDownvoted(limit int) (*SubmissionIterator, error)

func (*Redditor) ListGilded

func (usr *Redditor) ListGilded(limit int) (*SubmissionIterator, error)

func (*Redditor) ListHidden

func (usr *Redditor) ListHidden(limit int) (*SubmissionIterator, error)

func (*Redditor) ListSaved

func (usr *Redditor) ListSaved(limit int) (*SubmissionIterator, error)

func (*Redditor) ListSavedComments

func (usr *Redditor) ListSavedComments(limit int) (*CommentIterator, error)

func (*Redditor) ListSubmissions

func (usr *Redditor) ListSubmissions(limit int) (*SubmissionIterator, error)

func (*Redditor) ListUpvoted

func (usr *Redditor) ListUpvoted(limit int) (*SubmissionIterator, error)

func (*Redditor) Multireddits

func (usr *Redditor) Multireddits() ([]*Multireddit, error)

func (*Redditor) Report

func (usr *Redditor) Report(reason string) error

func (*Redditor) Unblock

func (usr *Redditor) Unblock() error

func (*Redditor) UserSubredditListNew

func (usr *Redditor) UserSubredditListNew(limit int) (*SubmissionIterator, error)

type Submission

type Submission struct {
	ID              string
	Author          string
	Archived        bool
	Author_fullname string
	Created         Timestamp
	Created_utc     Timestamp
	Clicked         bool
	Domain          string
	Hidden          bool
	Is_self         bool
	Is_video        bool
	Is_gallery      bool
	Locked          bool
	Num_comments    uint32
	Over_18         bool
	Permalink       string
	Saved           bool
	Score           int
	Selftext        string
	Spoiler         bool
	Stickied        bool
	Subreddit       string
	Title           string
	URL             string
	Upvote_ratio    float32
	Name            string
	Gallery_data    struct {
		Items []struct {
			Media_id string
		}
	}
	Media_metadata map[string]struct {
		M string
		S struct {
			X, Y int
			U    string
			Mp4  string
			Gif  string
		}
	}
	Preview struct {
		Images []struct {
			ID     string
			Source struct {
				URL           string
				Width, Height int
			}
		}
	}
	Crosspost_parent_list []*Submission
	Unrepliable_reason    string
	Author_is_blocked     bool
	// contains filtered or unexported fields
}

func (*Submission) ClearVote

func (sub *Submission) ClearVote() error

func (*Submission) Delete

func (sub *Submission) Delete() error

func (*Submission) Downvote

func (sub *Submission) Downvote() error

func (*Submission) Edit

func (sub *Submission) Edit(text string) error

func (*Submission) Hide

func (sub *Submission) Hide() error

func (*Submission) Reply

func (sub *Submission) Reply(text string) error

func (*Submission) Report

func (sub *Submission) Report(reason string) error

func (*Submission) Save

func (sub *Submission) Save() error

func (*Submission) Unhide

func (sub *Submission) Unhide() error

func (*Submission) Unsave

func (sub *Submission) Unsave() error

func (*Submission) Upvote

func (sub *Submission) Upvote() error

type SubmissionIterator

type SubmissionIterator struct {
	URL    string
	Reddit *Reddit
	// contains filtered or unexported fields
}

func (*SubmissionIterator) Buffered

func (iter *SubmissionIterator) Buffered() int

func (*SubmissionIterator) Count

func (iter *SubmissionIterator) Count() int

func (*SubmissionIterator) HasNext

func (iter *SubmissionIterator) HasNext() bool

func (*SubmissionIterator) Next

func (iter *SubmissionIterator) Next() (*Submission, error)

func (*SubmissionIterator) NextRequiresFetch

func (iter *SubmissionIterator) NextRequiresFetch() bool

type Subreddit

type Subreddit struct {
	ID                                                    string
	Active_user_count                                     int
	Created_utc                                           Timestamp
	Description                                           string
	Display_name                                          string
	Name                                                  string
	Over18                                                bool
	Public_description                                    string
	Subscribers                                           int
	User_is_banned, User_is_moderator, User_is_subscriber bool
	// contains filtered or unexported fields
}

func (*Subreddit) ListControversial

func (sub *Subreddit) ListControversial(limit int) (*SubmissionIterator, error)

func (*Subreddit) ListHot

func (sub *Subreddit) ListHot(limit int) (*SubmissionIterator, error)

func (*Subreddit) ListNew

func (sub *Subreddit) ListNew(limit int) (*SubmissionIterator, error)

func (*Subreddit) ListRising

func (sub *Subreddit) ListRising(limit int) (*SubmissionIterator, error)

func (*Subreddit) ListTop

func (sub *Subreddit) ListTop(limit int, t string) (*SubmissionIterator, error)

If t not specified, seems to default to "day"

func (*Subreddit) Search

func (sub *Subreddit) Search(limit int, q string, sort string, t string) (*SubmissionIterator, error)

func (*Subreddit) Subscribe

func (sub *Subreddit) Subscribe() error

func (*Subreddit) Unsubscribe

func (sub *Subreddit) Unsubscribe() error

type TSBool

type TSBool struct{ time.Time }

func (*TSBool) UnmarshalJSON

func (t *TSBool) UnmarshalJSON(b []byte) error

type Timestamp

type Timestamp struct{ time.Time }

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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