Skip to content
A golang client library for the official ProductHunt API.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


A golang client library for the official Product Hunt API.


Download and install gohunt by running go get

package main

import (

func main() {
	client := gohunt.NewUserClient("devToken")

	// Grab today's posts
	posts, err := client.GetPosts()
	if err != nil {

	// Print post summaries (Title: headline)
	for _, post := range posts {

Gohunt Client

Interaction with the Product Hunt API is facilitated by the Gohunt Client. The client can be generated in three ways:

Client-Only Authentication by OAuth2

client, err := gohunt.NewOAuthClient(clientID, clientSecret)

User-Authentication by Developer Token

client := gohunt.NewUserClient(phToken)

User-Authentication by OAuth2

func handleLogin(w http.ResponseWriter, r *http.Request) {
   gohunt.RequestUserOAuthCode(w, r, clientID, "/redir", state)

func handleRedirect(w http.ResponseWriter, r *http.Request) {
   client, err := gohunt.NewUserOAuthClient(clientID, clientSecret, "/me", r.FormValue("code"))

func main() {
   http.HandleFunc("/login", handleLogin)
   http.HandleFunc("/redir", handleRedirect)
   http.HandleFunc("/me", showUser)
   http.ListenAndServe(":3000", nil)

Client Interface

[param] indicates an optional parameter; use "" or -1 to exclude them in the request.

// Posts
client.GetPost(id int)
client.GetPreviousPosts(daysAgo int)
client.GetPostsOnDay(day string) // Formatted YYYY-MM-DD
client.GetAllPosts([searchUrl string], [olderThanID int], [newerThanID int], [count int])
client.CreatePost(link string, name string, tagline string)

// Users
client.GetUser(username string)  // id or username
client.GetAllUsers([olderThanID int], [newerThanID int], [count int], [order string])  // order is "asc" or "desc"

// Votes
client.GetPostVotes(postID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.GetUserVotes(userID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.VoteForPost(postID int, voting bool) // voting=false if unvoting; else true

// Comments
client.GetPostComments(postID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.GetUserComments(userID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.CreateComment(postID int, [parentCommentID int], body string)
client.UpdateComment(commentID int, [parentCommentID int], body string)

// Followers and Following
client.GetFollowers(userID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.GetFollowing(userID int, [olderThanID int], [newerThanID int], [count int], [order string])
client.Follow(userID int, following bool) // following=false if unfollowing; else true

// Related Links
client.GetRelatedLinks([searchUrl string])

// Requires User-Authenticated Client
client.GetNotifications([olderThanID int], [newerThanID int], [count int], [order string])
client.UpdateSettings(settings *UserSettings)

Missing Requests

Note: Write Access is provided by the Product Hunt team to specific entities, and rarely to third parties. All write-access requests are currently untested.

You can’t perform that action at this time.