# @kody/producthunt ## Intent Give any Kody account reusable Product Hunt helpers for **today’s posts**, lookups (posts, hunters, topics, collections), and **comments as allowed by the Product Hunt API**. The public GraphQL schema can read comments; it does not expose a comment-create mutation. Writes that *are* in the schema (goals and follow/unfollow) go through `./request` with `dryRun: true` / `confirm: true`. This listing is meant to be forked. After you fork, connect **your** Product Hunt app or developer token and run `./smoke-test` on **your** copy. Do not treat the live `@kody/producthunt` integration as yours. Share this package as https://kody.codes/@kody/producthunt (never a `/community/{listing_id}` URL). ## What it does - List today’s featured hunts without writing GraphQL by hand - Look up a post, hunter, topic, or collection by id or slug - Read comments on a post (`./list-comments`) - Call an unwrapped Product Hunt GraphQL operation through `./request` - Verify credentials with `./smoke-test` before building workflows Do not use this package as a scraper, a place to paste access tokens, or a comment poster — Product Hunt’s public API does not expose comment writes. ## Prerequisites / setup Product Hunt has **no built-in Kody OAuth app**. Tokens come from a bring-your-own confidential OAuth app or a developer token saved as a user secret. Never paste a client secret or access token into chat. Required API host: **`api.producthunt.com`**. Approve it in the account secrets UI. Saving a secret does not approve hosts by itself. | Lane | When to use | Credential | | --- | --- | --- | | **OAuth** (recommended) | Connected hunter (`viewer`), private fields, refreshable tokens | Saved integration `producthunt` or `producthunt-` | | **Developer token** | Public reads when you only have a dashboard token | User secret `producthuntAccessToken` (or `producthuntAccessToken-`) | ### Lane A — BYO OAuth 1. Create a **Confidential** OAuth app at [Product Hunt API applications](https://api.producthunt.com/v2/oauth/applications). Public clients cannot store the secret Kody needs. 2. Register the redirect URI **exactly** as `https://kody.codes/connect/oauth`. 3. Request scopes `public` and `private` (space-separated). Add `write` only when Product Hunt has approved your app for mutations. 4. Open this prefilled connect URL while signed in to Kody: https://kody.codes/connect/oauth?provider=producthunt&authorizeUrl=https%3A%2F%2Fapi.producthunt.com%2Fv2%2Foauth%2Fauthorize&tokenUrl=https%3A%2F%2Fapi.producthunt.com%2Fv2%2Foauth%2Ftoken&apiBaseUrl=https%3A%2F%2Fapi.producthunt.com%2Fv2%2Fapi%2Fgraphql&flow=confidential&allowedHosts=api.producthunt.com&dashboardUrl=https%3A%2F%2Fapi.producthunt.com%2Fv2%2Foauth%2Fapplications&scopes=public%20private 5. Paste the Client ID and Client Secret into the Kody form (not into chat). If you need to save the client secret yourself first: https://kody.codes/account/secrets/new?name=producthuntClientSecret&description=Product%20Hunt%20OAuth%20client%20secret%20for%20the%20confidential%20app&allowedHosts=api.producthunt.com&scope=user 6. Approve host `api.producthunt.com`. 7. Reconnect later with https://kody.codes/connect/oauth?provider=producthunt Decoded connect fields: - Redirect / callback: `https://kody.codes/connect/oauth` - Authorize: `https://api.producthunt.com/v2/oauth/authorize` - Token: `https://api.producthunt.com/v2/oauth/token` - API: `https://api.producthunt.com/v2/api/graphql` - Flow: `confidential` - Host: `api.producthunt.com` - Scopes: `public`, `private` To connect a second account, change `provider` (for example `provider=producthunt-work`) and pass `account: 'work'` or `integrationName: 'producthunt-work'` on every call. ### Lane B — Developer / access token 1. Create or copy a developer token from the same [API applications](https://api.producthunt.com/v2/oauth/applications) page. 2. Save it (do not paste the value in chat): https://kody.codes/account/secrets/new?name=producthuntAccessToken&description=Product%20Hunt%20developer%20or%20OAuth%20access%20token%20for%20GraphQL%20reads&allowedHosts=api.producthunt.com&scope=user 3. Approve host `api.producthunt.com`. 4. For a second token use `producthuntAccessToken-work` and pass `secretName: 'producthuntAccessToken-work'` (or `account: 'work'`). ### Scopes | Scope | Needed for | | --- | --- | | `public` | Featured posts, lookups, comments, topics, collections | | `private` | `./get-viewer` (`viewer.user`) | | `write` | Goal and follow mutations via `./request` (Product Hunt must approve the app) | ### Mutation safety (summary) The public schema’s mutations are goals and user follow/unfollow — not comments. `./request` treats query documents as read-only. Mutation documents need `confirm: true`. Pass `dryRun: true` to inspect the payload without calling Product Hunt. Agents: see [`AGENTS.md`](./AGENTS.md) for import paths, smoke checks, and GraphQL snippets. ## Done when - `producthunt` OAuth is connected (`public` + `private`) **or** `producthuntAccessToken` is saved; host `api.producthunt.com` is approved - Smoke test returns `{ ok: true, live: true, hasViewer, todayPostCount }` without hunter PII, or `{ live: false }` plus setup URLs - Mutations via `./request` preview with `dryRun: true` and only run live with `confirm: true` after Product Hunt has approved `write` when needed ## Docs - [Product Hunt API](https://api.producthunt.com/v2/docs) - [OAuth applications](https://api.producthunt.com/v2/oauth/applications)