https://github.com/vtnerd/grokeddit
Library for interacting with Reddit API in Go!
https://github.com/vtnerd/grokeddit
Last synced: about 1 year ago
JSON representation
Library for interacting with Reddit API in Go!
- Host: GitHub
- URL: https://github.com/vtnerd/grokeddit
- Owner: vtnerd
- License: unlicense
- Created: 2014-05-04T17:49:38.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-11-24T01:04:46.000Z (over 11 years ago)
- Last Synced: 2025-02-13T05:43:53.637Z (over 1 year ago)
- Language: Go
- Size: 301 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
grokeddit
=========
Library for interacting with Reddit API in Go! The library provides an easy interface for retrieving links and comments from Reddit. Example:
```go
subredditsHandle, error := fetcheddit.FetchSubreddits([]string{"music", "movies"}, fetcheddit.DefaultFetch)
if error != nil {
return error
}
links, error := subredditsHandle.FetchNewLinks(nil)
if error != nil {
return error
}
for links.HasNext() {
link, error := links.GetNext()
if error != nil {
return error
}
log.Printf("Link Title: %s", link.Title)
}
```
The library automatically fetches a block of elements on a separate goroutine. This allows for a range style interface (the user is not exposed to the individual blocks of elements retrieved), and interleaving of processing and retrieval (elements are being traversed while the OS is waiting for Reddit to respond with the next block of elements).
_This library is a work-in-progress and should be used with caution. The API is unlikely to change, but more tests and features are likely needed to make it usuable for your project. The library does not support writing to Reddit, which may be implemented at a later time._
Design
------
The library is split into two parts:
1. The **grokeddit** package parses the JSON and massages the data from the server to more relevant types (less strings).
2. The **fetcheddit** package intelligently retrieves JSON documents, passes the information to grokeddit, then strips unused fields (based on context). Most users will want to use this package, instead of directly using grokeddit.