{"id":22381427,"url":"https://github.com/miguelo981/node-producthunt-api","last_synced_at":"2025-10-15T19:16:21.061Z","repository":{"id":175277670,"uuid":"653394104","full_name":"Miguelo981/node-producthunt-api","owner":"Miguelo981","description":"Node.js wrapper for the Product Hunt Graphql API V2","archived":false,"fork":false,"pushed_at":"2023-10-24T11:47:14.000Z","size":60,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-10T07:53:26.221Z","etag":null,"topics":["grapql","nodejs","npm-package","producthunt","producthunt-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miguelo981.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-14T01:18:16.000Z","updated_at":"2025-05-10T19:26:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"383224b6-909d-4134-a685-0af4d5b36596","html_url":"https://github.com/Miguelo981/node-producthunt-api","commit_stats":null,"previous_names":["miguelo981/node-producthunt-api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Miguelo981/node-producthunt-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguelo981%2Fnode-producthunt-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguelo981%2Fnode-producthunt-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguelo981%2Fnode-producthunt-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguelo981%2Fnode-producthunt-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miguelo981","download_url":"https://codeload.github.com/Miguelo981/node-producthunt-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguelo981%2Fnode-producthunt-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260221391,"owners_count":22976865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grapql","nodejs","npm-package","producthunt","producthunt-api"],"created_at":"2024-12-05T00:09:02.625Z","updated_at":"2025-10-15T19:16:16.024Z","avatar_url":"https://github.com/Miguelo981.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Product Hunt API V2 Node.js Library\nThe Product Hunt Node.js library provides convenient access to the Product Hunt Graphql V2 API from Node.js applications.\n\n\u003e ⚠️ **Important note: this library is meant for server-side usage only, as using it in client-side browser code will expose your secret API key. [See here](https://api.producthunt.com/v2/docs) for more details.**\n\n## Installation\n\n```bash\nnpm install node-producthunt-api\n```\n\n## Usage\n\nThe library needs to be configured with your account's secret key, which is available in your [Product Hunt account page]([https://platform.openai.com/account/api-keys](https://www.producthunt.com/v2/oauth/applications)). We recommend setting it as an environment variable. Here's an example of initializing the library with the API key loaded from an environment variable and creating a completion:\n\n## Init client\n\nYou can use your app dev token directly:\n\n```javascript\nconst { Configuration, ProductHuntAPI } = require(\"node-producthunt-api\");\n\nconst configuration = new Configuration({\n        apiKey: process.env.PRODUCT_HUNT_DEV_TOKEN,\n})\n```\n\nor use your Oauth credentials If you have no token created:\n\n```javascript\nconst { Configuration, ProductHuntAPI } = require(\"node-producthunt-api\");\n\nconst configuration = new Configuration({\n        clientId: process.env.PRODUCT_HUNT_CLIENT_ID,\n        clientSecret: process.env.PRODUCT_HUNT_CLIENT_SECRET,\n        grantType: \"client_credentials\",\n})\n```\n\n```javascript\nconst { ProductHuntAPI } = require(\"node-producthunt-api\");\n\nconst productHuntAPI = new ProductHuntAPI(configuration)\n\nconst { data } = await productHuntAPI\n  .GetPosts({\n    variables: {\n      first: 20,\n      order: \"VOTES\",\n      postedAfter: new Date(\"2022/12/01\"),\n      after: \"NjA\",\n      topic: \"web3\"\n    }\n  })\nconsole.log(data.data.posts.edges)\n```\n\nCheck out the [full API documentation](http://api-v2-docs.producthunt.com.s3-website-us-east-1.amazonaws.com/object/post/) for examples of all the available functions.\n\n### Request options\n\nAll of the available API request functions additionally contain an optional final parameter where you can pass custom [axios request options](https://axios-http.com/docs/req_config), for example:\n\n```javascript\nconst completion = await productHuntAPI\n  .GetPosts(\n    {\n      variables: {\n        first: 20,\n        order: \"VOTES\"\n      }\n    },\n    {\n      timeout: 1000,\n      headers: {\n        \"Example-Header\": \"example\",\n      },\n    }\n  );\n```\n\n### CommonJs and ESModules Support\n\n```javascript\nconst { Configuration, ProductHuntAPI } = require(\"node-producthunt-api\");\n```\n\n```javascript\nimport { Configuration, ProductHuntAPI } from \"node-producthunt-api\"\n```\n\n### Error handling\n\nAPI requests can potentially return errors due to invalid inputs or other issues. These errors can be handled with a `try...catch` statement, and the error details can be found in either `error.response` or `error.message`:\n\n```javascript\ntry {\n  const { data } = await productHuntAPI\n  .GetPosts({\n      variables: {\n        first: 20,\n        order: \"VOTES\"\n      }\n  });\n  console.log(data.data.posts.edges);\n} catch (error) {\n  if (error.response) {\n    console.log(error.response.status);\n    console.log(error.response.data);\n  } else {\n    console.log(error.message);\n  }\n}\n```\n\n\n### Roadmap\n\n- [x] Support Typescript typing\n- [x] Support for Oauth token middleware\n- [x] Add GetPosts query\n- [x] Add GetTopics query\n- [x] Add GetPost query\n- [x] Support dev token\n- [ ] Add GetTopic query\n- [ ] Add GetCollection/s query\n- [ ] Add GetViewer/s query\n- [ ] Add GetUser/s query\n- [ ] Add GetMakerGroup/s query\n- [ ] Add GetGoal/s query\n- [ ] Add GetComment/s query\n- [ ] Add mutation/s support","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelo981%2Fnode-producthunt-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiguelo981%2Fnode-producthunt-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelo981%2Fnode-producthunt-api/lists"}