Skip to content
Product Hunt API
JavaScript HTML CSS
Branch: master
Clone or download
Latest commit bee7dc7 Jun 3, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client Add starter kit for V2 May 20, 2019
routes Add starter kit for V2 May 20, 2019
.env.sample Add starter kit for V2 May 20, 2019
.gitignore Add starter kit for V2 May 20, 2019
.nvmrc Add starter kit for V2 May 20, 2019
README.md fixed the API explorer link May 21, 2019
index.js Add starter kit for V2 May 20, 2019
package.json
schema.graphql Update schema Jun 3, 2019
schema.json Update schema Jun 3, 2019
yarn.lock Add starter kit for V2 May 20, 2019

README.md

Welcome to Product Hunt API 2.0 Starter Kit

This is a minimal starter kit that integrates with Product Hunt's API V2 via OAuth flow.

Dependencies

  • node >= 8.15
  • npm or yarn
  • openssl

Setup

  1. Create an OAuth application via API Dashboard

  2. git clone git@github.com:producthunt/producthunt-api.git

  3. yarn or npm install

  4. cp .env.sample .env.

  5. Update PH_APP_API_KEY & PH_APP_API_SECRET, PH_APP_REDIRECT_URI & PH_APP_REQUESTED_SCOPES values in .env file.

  6. Only needed for local development: Generate self-signed certificate to run app on https locally. openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.cert

  7. yarn build - creates a production ready build of the React app.

  8. yarn start - starts the application server on port 3000.

  9. open https://localhost:3000.

Development

  • All requests made by React app to /graphql are proxied to the PH API. The user access token is encrypted and stored in the session cookie.

  • If your app only requires public scope token, you can fetch one using the command below and put it in the .env file under PH_APP_CLIENT_CREDENTIALS_TOKEN

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"client_id":"YOUR_API_KEY_HERE","client_secret":"YOUR_API_SECRET_HERE", "grant_type": "client_credentials"}' \
  https://api.producthunt.com/v2/oauth/token
  • Use ENABLE_HTTPS=true in .env file while developing locally.

  • Change made to the React app need to be rebuilt every time using yarn build. This is not ideal and needs to be migrated to HMR to ease development, PRs for same are appreciated :)

API

The API supports 3 scopes as of now:

public - Allows to access public information on Product Hunt.

private - Allows to access Product Hunt on behalf of the authenticated user. e.g Read goals of the user.

write - Allows to write data to Product Hunt on behalf of the authenticated user. e.g Mark goals of user as complete/incomplete.

Useful Links:

For feedback, requests and bugs please visit: https://github.com/producthunt/producthunt-api/issues

Happy Hacking!

You can’t perform that action at this time.