Skip to content
← Public packages

@kody/producthunt

Read today's Product Hunt posts, lookups, and comments through the saved Product Hunt OAuth integration.

FollowFork

Files

AGENTS.md

117 lines · 3.9 KB · Markdown

@kody/producthunt — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke/dryRun execute snippets, and edge cases. Secrets by name only — never paste key values. Do not disable live webhooks or jobs.

Auth

LaneCredentialNotes
A (recommended)Integration producthunt (or producthunt-<purpose>)BYO confidential OAuth. Host api.producthunt.com.
BUser secret producthuntAccessTokenDeveloper / access token Bearer.

Every export accepts account, integrationName / integration, secretName, and auth: "oauth" | "token" when both exist. account: "work" → producthunt-work / producthuntAccessToken-work. Optional secret name for the client secret: producthuntClientSecret. GraphQL: https://api.producthunt.com/v2/api/graphql. Placeholders: {{secret:producthuntAccessToken|scope=user}}. Do not hard-code a hunter username or post slug.

Import paths

ExportImport
overview / action dispatcherkody:@kody/producthunt
accountskody:@kody/producthunt/accounts
smoke-testkody:@kody/producthunt/smoke-test
guidekody:@kody/producthunt/guide
list-today-postskody:@kody/producthunt/list-today-posts
list-postskody:@kody/producthunt/list-posts
get-postkody:@kody/producthunt/get-post
list-commentskody:@kody/producthunt/list-comments
get-userkody:@kody/producthunt/get-user
get-viewerkody:@kody/producthunt/get-viewer
get-topickody:@kody/producthunt/get-topic
list-topicskody:@kody/producthunt/list-topics
get-collectionkody:@kody/producthunt/get-collection
list-collectionskody:@kody/producthunt/list-collections
request (escape hatch)kody:@kody/producthunt/request
typeskody:@kody/producthunt/types

Prefer static kody:@kody/producthunt/... imports from execute. Do not lead with packages.invoke. Page sizes are clamped to 1–20.

Smoke test (read-only)

import smokeTest from 'kody:@kody/producthunt/smoke-test'

export default async function main() {
	return await smokeTest()
	// without creds => { ok: true, live: false, setup: { ...URLs } }
	// with creds => { live: true, hasViewer, todayPostCount } (no hunter PII)
}

Or through the root export:

import producthunt from 'kody:@kody/producthunt'

export default async function main() {
	return await producthunt({ action: 'smoke-test' })
}

Common snippets

import listTodayPosts from 'kody:@kody/producthunt/list-today-posts'

export default async function main() {
	return await listTodayPosts({ first: 5 })
}
import getPost from 'kody:@kody/producthunt/get-post'
import listComments from 'kody:@kody/producthunt/list-comments'

export default async function main() {
	const post = await getPost({ slug: 'some-product-slug' })
	const comments = await listComments({ slug: post.slug, first: 10 })
	return { post, comments }
}

dryRun / confirm (writes)

Public schema mutations are goals and follow/unfollow — not comments. ./request treats query documents as read-only. Mutation documents need confirm: true. Pass dryRun: true to inspect the payload:

import request from 'kody:@kody/producthunt/request'

export default async function main() {
	return await request({
		query: `mutation FollowUser($userId: ID!) { userFollow(input: { userId: $userId }) { user { id } } }`,
		variables: { userId: 'user-id-from-caller' },
		dryRun: true,
	})
}

Edge cases / troubleshooting

  • Connect page asks for authorize/token URLs → use the full first-time URL in README Lane A
  • HTTP 401 / expired token → reconnect https://kody.codes/connect/oauth?provider=producthunt
  • viewer.user empty → reconnect with private scope
  • Mutation FORBIDDEN → Product Hunt must approve write, then reconnect
  • redirect_uri mismatch → app redirect must be exactly https://kody.codes/connect/oauth