producthunt

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package producthunt is the library behind the ph command: the HTTP client, request shaping, and the typed data models for Product Hunt.

Data source: the public Atom feed at https://www.producthunt.com/feed. No authentication or API key is required.

Index

Constants

View Source
const DefaultUserAgent = "ph/dev (+https://github.com/tamnd/producthunt-cli)"

DefaultUserAgent identifies the client to Product Hunt.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to Product Hunt over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client built from cfg.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

func (*Client) Today

func (c *Client) Today(ctx context.Context, limit int) ([]Product, error)

Today fetches the Product Hunt Atom feed and returns up to limit Product records. If limit is 0 or greater than the number of entries in the feed, all entries are returned.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
}

Config holds constructor parameters for Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults: no rate limiting (one request per command), two retries on transient errors, and a 30-second timeout.

type Product

type Product struct {
	Rank      int    `json:"rank"`
	Name      string `json:"name"`
	Tagline   string `json:"tagline"`
	Author    string `json:"author"`
	Published string `json:"published"`
	URL       string `json:"url"`
}

Product is the record emitted for each Product Hunt launch from the feed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL