Categorygithub.com/CheatCoder/geddit
modulepackage
0.0.0-20210711205914-a80583139dcb
Repository: https://github.com/cheatcoder/geddit.git
Documentation: pkg.go.dev

# README

geddit

GoDoc Go Report Card Build Status

Geddit is a convenient abstraction for the reddit.com API in Go. This library is a WIP. It should have some API coverage, but does not yet include things like the new OAuth model.

examples

See godoc for OAuth examples.

Here is an example usage of the old, cookie authentication method:

(NOTE: You will be heavily rate-limited by reddit's API when using cookies. Consider switching to OAuth).

package main

import (
	"fmt"

	"github.com/jzelinskie/geddit"
)

// Please don't handle errors this way.
func main() {
	// Login to reddit
	session, _ := geddit.NewLoginSession(
		"novelty_account",
		"password",
		"gedditAgent v1",
	)

	// Set listing options
	subOpts := geddit.ListingOptions{
		Limit: 10,
	}

	// Get reddit's default frontpage
	submissions, _ := session.DefaultFrontpage(geddit.DefaultPopularity, subOpts)

	// Get our own personal frontpage
	submissions, _ = session.Frontpage(geddit.DefaultPopularity, subOpts)

	// Get specific subreddit submissions, sorted by new
	submissions, _ = session.SubredditSubmissions("hockey", geddit.NewSubmissions, subOpts)

	// Print title and author of each submission
	for _, s := range submissions {
		fmt.Printf("Title: %s\nAuthor: %s\n\n", s.Title, s.Author)
	}

	// Upvote the first post
	session.Vote(submissions[0], geddit.UpVote)
}

# Functions

NewLinkSubmission returns a NewSubmission with parameters appropriate for a link submission.
NewLoginSession creates a new session for those who want to log into a reddit account.
NewOAuthSession creates a new session for those who want to log into a reddit account via OAuth.
NewSession creates a new unauthenticated session to reddit.com.
NewTextSubmission returns a NewSubmission with parameters appropriate for a text submission.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
Comment represents a reddit comment.
No description provided by the author
No description provided by the author
No description provided by the author
LoginSession represents an HTTP session with reddit.com -- all authenticated API calls are methods bound to this type.
NewSubmission contains the data needed to submit.
OAuthSession represents an OAuth session with reddit.com -- all authenticated API calls are methods bound to this type.
No description provided by the author
No description provided by the author
Session represents an HTTP session with reddit.com without logging into an account.
Submission represents an individual post from the perspective of a subreddit.
Subreddit represents a subreddit from reddit.com.
No description provided by the author

# Interfaces

Deleter represents something that can be deleted on reddit.com.
Replier represents something that can be replied to on reddit.com.
Voter represents something that can be voted on reddit.com.

# Type aliases

PopularitySort represents the possible ways to sort submissions by popularity.
vote represents the three possible states of a vote on reddit.