Need help with go-reddit?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

210 Stars 32 Forks Other 206 Commits 14 Opened issues


Go library for accessing the Reddit API.

Services available


Need anything else?

Contributors list

go-reddit logo

Actions Status Go Report Card PkgGoDev


Featured in issues 327 and 347 of Golang Weekly 🎉

go-reddit is a Go client library for accessing the Reddit API.

You can view Reddit's official API documentation here.


To get a specific version from the list of versions:

go get[email protected]

Or for the latest version:

go get

The repository structure for managing multiple major versions follows the one outlined here.


Make sure to have a Reddit app with a valid client id and secret. Here is a quick guide on how to create an app and get credentials.

package main

import ""

func main() { credentials := reddit.Credentials{ID: "id", Secret: "secret", Username: "username", Password: "password"} client, _ := reddit.NewClient(credentials) }

You can pass in a number of options to

to further configure the client (see reddit/reddit-options.go). For example, to use a custom HTTP client:
httpClient := &http.Client{Timeout: time.Second * 30}
client, _ := reddit.NewClient(credentials, reddit.WithHTTPClient(httpClient))

Read-Only Mode


method returns a valid, read-only client with limited access to the Reddit API, much like a logged out user. You can initialize your own and configure it further using options via
client, _ := reddit.NewReadonlyClient()


Configure the client from environment variables. When using this option, it's ok to pass an empty struct for the credentials.
client, _ := reddit.NewClient(reddit.Credentials{}, reddit.FromEnv)
Submit a comment.
comment, _, err := client.Comment.Submit(context.Background(), "t3_postid", "comment body")
if err != nil {
    return err
fmt.Printf("Comment permalink: %s\n", comment.Permalink)
Upvote a post.
_, err := client.Post.Upvote(context.Background(), "t3_postid")
if err != nil {
    return err
Get r/golang's top 5 posts of all time.
posts, _, err := client.Subreddit.TopPosts(context.Background(), "golang", &reddit.ListPostOptions{
    ListOptions: reddit.ListOptions{
        Limit: 5,
    Time: "all",
if err != nil {
    return err
fmt.Printf("Received %d posts.\n", len(posts))

More examples are available in the examples folder.


The package design is heavily inspired from Google's GitHub API client and DigitalOcean's API client.


Contributions are welcome! For any bug reports/feature requests, feel free to open an issue or submit a pull request.


This project is licensed under the MIT License - see the LICENSE file for details.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.