Skip to content

Reddit API in Go (Golang)

You can call Reddit data from Go (Golang) using only net/http. The example below searches posts and prints the response. You don't need a third-party package or a Reddit app.

Try a Reddit search in your browserThen copy the Go program below.
Reddit api golang: a burrowing gopher-like creature in a tidy underground library handing a scroll through a round window to the surface.

The job

Go services often pull Reddit data for monitoring or enrichment. A plain http.NewRequest with an Authorization header is enough. Decode the JSON into your own struct.

The recorded response below shows which fields to map. To page through results, pass nextCursor into the next request.

How it works

  1. Set the key

    Export CHATTERAPI_KEY and read it with os.Getenv.

  2. Send the request

    Build a GET to /v1/reddit/search with url.Values and set the Authorization header. The full program is below.

  3. Decode into a struct

    Use encoding/json with a struct holding the fields you need, such as title, score and createdAt.

Endpoints that do it

EndpointWhat it's forCredits
Search postsGET /v1/reddit/searchPosts by keyword.2 credits
List subreddit postsGET /v1/reddit/subreddits/{name}/postsA community's posts.2 credits
Get a thread with commentsGET /v1/reddit/threads/{id}A post with its comments.3 credits

Free tools for the same job

Try the job in a browser first. These tools call the same endpoints, and you don't need a key or any code.

A complete Go program and a recorded response

The program prints the HTTP status and the JSON body. Below is a recorded response for a similar request.

main.go: search Reddit with net/http
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
)

func main() {
	q := url.Values{"q": {"best crm for small business"}, "time": {"year"}}
	req, _ := http.NewRequest("GET", "https://api.chatterapi.com/v1/reddit/search?"+q.Encode(), nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATTERAPI_KEY"))

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)
	fmt.Println(res.Status)
	fmt.Println(string(body))
}
curl "https://api.chatterapi.com/v1/reddit/search?q=best+crm+for+small+business&time=year" \
  -H "Authorization: Bearer $CHATTERAPI_KEY"
response, first 2 rows
{
  "data": [
    {
      "id": "1wdihhj",
      "fullname": "t3_1wdihhj",
      "title": "What CRM should a small business use?",
      "body": "We’re a small B2B business with 6 people and sales is still pretty founder led, but revenue has grown enough that keeping leads, follow ups and customer conversations spread across spreadsheets and inboxes is starting to…",
      "author": "NotedWhisky",
      "subreddit": "CRM",
      "permalink": "/r/CRM/comments/1wdihhj/what_crm_should_a_small_business_use/",
      "url": "https://www.reddit.com/r/CRM/comments/1wdihhj/what_crm_should_a_small_business_use/",
      "externalUrl": null,
      "score": 51,
      "numComments": 186,
      "upvoteRatio": null,
      "createdAt": "2026-09-11T14:52:16.000Z",
      "nsfw": false,
      "locked": null,
      "media": null
    },
    {
      "id": "1vmy4xb",
      "fullname": "t3_1vmy4xb",
      "title": "If You Had to Pick the Best CRM for Small Business Today, What Would It Be?",
      "body": "I've spent the last few days reading reviews and watching videos, and somehow I'm even more undecided than when I started.\n\nEvery CRM looks amazing on its website, but that doesn't tell you what it's like after you've be…",
      "author": "Living_Dependent242",
      "subreddit": "CRMSoftware",
      "permalink": "/r/CRMSoftware/comments/1vmy4xb/if_you_had_to_pick_the_best_crm_for_small/",
      "url": "https://www.reddit.com/r/CRMSoftware/comments/1vmy4xb/if_you_had_to_pick_the_best_crm_for_small/",
      "externalUrl": null,
      "score": 10,
      "numComments": 56,
      "upvoteRatio": null,
      "createdAt": "2026-08-13T02:25:31.000Z",
      "nsfw": false,
      "locked": null,
      "media": null
    }
  ],
  "page": {
    "nextCursor": "AX-v…",
    "hasMore": true
  }
}

Recorded from a live call on . Long text is shortened and the cursor is cut. A live key is charged 2 credits for this call. A test key returns this same sample for 0 credits.

What it won't do

  • This Go code is a minimal example. For production, add timeouts and retries.
  • Reddit is read-only here.
  • Removed content is not returned.

Questions

Is there a Go SDK?
No. The standard library is enough.
How do I set a timeout?
Use http.Client{Timeout: 20 * time.Second} instead of the default client.
Can I use it from a Lambda or Cloud Run service?
Yes. Pass the key in an environment variable.

Other languages

Build it with one API key

Try it free for 7 days with 1,000 credits.