Git Product home page Git Product logo

producthunt-api's Introduction

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 [email protected]: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!

producthunt-api's People

Contributors

rstankov avatar dependabot[bot] avatar dhruvparmar372 avatar andreasklinger avatar bryzgaloff avatar asudhakar avatar swarooph avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.