@kentcdodds/producthunt
README.md
71 lines · 3.2 KB · Markdown@kentcdodds/producthunt
Intent
Give Kody agents a reusable Product Hunt helpers surface: one generic GraphQL request util plus common read helpers for posts, hunters, topics, collections, and comments. The saved producthunt OAuth integration is credentials only; this package is how agents should call Product Hunt.
When To Use
- Look up today's hunts, a post by slug, or a hunter by username
- Read comments, topics, and collections without writing GraphQL by hand
- Call any Product Hunt GraphQL operation (including mutations) through
request - Verify the saved Product Hunt OAuth integration before building workflows
Install
This is a Kody package. After it is saved/published in your Kody account (or forked from the community listing), import it with the kody: specifier:
import listPosts from 'kody:@kentcdodds/producthunt/list-posts'Required setup
- Create a Confidential Product Hunt OAuth app at https://api.producthunt.com/v2/oauth/applications
- Redirect URI:
https://kody.codes/connect/oauth(or your Kody origin plus/connect/oauth) - Connect with
publicandprivatescopes using theguideexport - Saved OAuth integration name:
producthunt - Approve host:
api.producthunt.com
Public scope is enough for featured posts. Private scope is required for viewer.user (the connected hunter). Write mutations need Product Hunt app approval and the write scope.
Usage
import listPosts from 'kody:@kentcdodds/producthunt/list-posts'
import getPost from 'kody:@kentcdodds/producthunt/get-post'
import getViewer from 'kody:@kentcdodds/producthunt/get-viewer'
import request from 'kody:@kentcdodds/producthunt/request'
const featured = await listPosts({ featured: true, first: 5, order: 'RANKING' })
const post = await getPost({ slug: 'clara-ai-sdr' })
const me = await getViewer()
const raw = await request({
query: `query TopicBySlug($slug: String!) { topic(slug: $slug) { id name slug } }`,
variables: { slug: 'developer-tools' },
})Exports
./— package overview and setup metadata./types— exported TypeScript type name catalog./request— authenticated Product Hunt GraphQL helper./smoke-test— verify auth with viewer plus one featured post./guide— connect URL and setup notes ({ origin?: string })./get-viewer— connected hunter (privatescope)./get-user— hunter byidorusername./get-post— post byidorslug./list-posts— paginated posts (featured, date window, topic, order)./list-comments— comments on a post./get-collection— collection byidorslug./list-collections— paginated collections./get-topic— topic byidorslug./list-topics— paginated topics (querysearch supported)
Read helpers only. Use request for uncommon queries or mutations. Page sizes are clamped to 1–20 to match the Product Hunt API.
Auth / transport
There is no Product Hunt OpenAPI surface. This package uses createAuthenticatedFetch('producthunt') against https://api.producthunt.com/v2/api/graphql. Pass integration when the saved connection is not named producthunt.