Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/sridharv/reddit-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sridharv/reddit-go

  • v0.0.0-20160818080055-682b83c99eda
  • Source
  • Go
  • Socket score

Version published
Created
Source

Minimal Reddit API wrapper for Go.

This is a work in progress and may contain bugs. It has only been tested for the top posts query.

The GoDoc contains detailed documentation. The package examples contain details on how to use the package.

Please read the reddit API documentation first before reading these docs. Some useful links are:

This currently only supports OAuth for script apps. It does not support refreshing OAuth tokens. It provides the following:

  • Code to save and load authorization credentials (client id, client secret, etc).
  • A simple API to obtain and store an OAuth token for a script app using these credentials.
  • An API to perform GET requests using the obtained token.
  • An API to stream listings.

Example Usage

cfg, err := reddit.LoadConfig(reddit.DefaultConfigFile)
if err != nil {
    log.Fatal(err)
}
if err := cfg.AuthScript(http.DefaultClient); err != nil {
    log.Fatal(err)
}
// Print top posts of the day from /r/golang
stream := cfg.Stream(http.DefaultClient, &reddit.TopPosts{SubReddit: "golang", Duration: reddit.TopDay})
for stream.Next() {
    thing := stream.Thing()
    link := thing.Data.(*reddit.Link)
    fmt.Println(link.Title, link.URL)
}
if err := stream.Error(); err != nil {
    log.Fatal(err)
}

FAQs

Package last updated on 18 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc