API Support

Dhruv Parmar
127 replies
Facing any issues with the API? Share them here

Replies

Sam Ben
NewsletterStash
NewsletterStash
@dhruvparmar Thanks for adding makers and media. Any plans on adding reviews query?
Dhruv Parmar
@ossamaweb we are currently working on internal changes to reviews. They will be added to the API post that.
Sam Ben
NewsletterStash
NewsletterStash
@dhruvparmar Is there a way to know which images are GIFs and which are static from media field?
Dhruv Parmar
@ossamaweb I'm afraid not and we do not plan to expose that information.
Sam Ben
NewsletterStash
NewsletterStash
@dhruvparmar Thanks. I'll figure something out. I see that the order of media in the API is different than that on the website. is that bug or website uses some type of sorting?
Sarun W.
Screenshot Studio
Screenshot Studio
@dhruvparmar would be good if we can filter goals currently in focus mode.
Dhruv Parmar
@sarunw hey, that's a good suggestion. I'll update here once we implement that.
Vasanth
@dhruvparmar Is there a way to upvote using this API? I don't see a mutation for that? Also, what will be the validity for the access_grant_token & access_token?
Dhruv Parmar
@vsnthv Currently we don't allow upvotes via the API. The access_token is long lived(never expires) and access_grant_token expires in 20m.
Knight 
@dhruvparmar hi, still pretty new on this graphql things, but it seem like no way to filter the records ? like if I want to filter all my goals that complete only ? I can only fetch all and filter locally ?
Dhruv Parmar
@imknight hey, you can filter "goals" by using "completed" flag here http://api-v2-docs.producthunt.c... Setting `completed: true` on the query will result in only completed goals being fetched.
Knight 
@dhruvparmar Got it , i use Viewer to check, is a bit funny, when checking own goal cannot filter by using completed flag
Knight 
@dhruvparmar the same mutation work on API Explorer and not on local dev, could that my account not grant for write access scope ? but I already apply, will I get a confirmation ?
Dhruv Parmar
@imknight I've approved write access for your application. Let me know incase you're facing issues with mutations still.
Dhruv Parmar
API Update: We've added support to fetch "goals" & "goal(id: goalId)" to the API. Check out http://api-v2-docs.producthunt.c... cc @jpeguin1
JPEGuin
@dhruvparmar Seems like doing a "goals" query keeps returning a 204 (no content) for me. It works fine from the API explorer, but any call to this endpoint from my code succeeds but doesn't return anything. Any idea on what may be up with this? EDIT: This has now been resolved on the server-side.
JPEGuin
@dhruvparmar This is great stuff, thanks!
Dhruv Parmar
Hey everyone! Dhruv from the engineering team at Product Hunt. The new version for the Product Hunt public API is built using GraphQL. We want you to have a smooth experience while integrating with the API and I'll be here to assist you in any issues that might arise. Here are some quick tips to get started: 1. To explore the GraphQL interface of the API quickly, you can use the GraphiQL Explorer app. 2. We've published a minimal Node + React App as a starter kit on Github here. Happy Hacking 💻🚀!
Akshay Ashok
@dhruvparmar I'm trying minimal Node + React App as a starter kit, but on clicking Login with product hunt, it get redirected to /authorize but nothing seems to happen. also there is this POST http://localhost:3001/graphql 404 (Not Found) in console.
Dhruv Parmar
@akshay_ashok1 Hey, please make sure to copy `.env.sample` file and rename it to `.env` file in your project root. Also update all `PH_` variables in the `.env` file to appropriate values. I'm guessing there is an issue with the environment variables.
Akshay Ashok
@dhruvparmar I can't figure out the client Credential token part
Dhruv Parmar
API Update: We've added support to fetch "makers" & "media" for each Post item. Check out http://api-v2-docs.producthunt.c... cc @ossamaweb @asingh2
JPEGuin
@ossamaweb @asingh2 @dhruvparmar Awesome, is this also reflected in the API explorer?
Dhruv Parmar
@jpeguin1 yes, the API explorer has the new fields.
Sam Ben
NewsletterStash
NewsletterStash
@asingh2 @dhruvparmar Awesome! Thanks man ;)
Dhruv Parmar
We've made following updates to the API: 1. Added `GoalCreate` mutation which allows to create goals on behalf of the authenticated user. http://api-v2-docs.producthunt.c... 2. Added `videoUrl` field to `media` object for Posts. http://api-v2-docs.producthunt.c... 3. Fixes to `GoalUpdate` mutation. 4. Fixed order of `media` items for Post. For further details check out the GraphQL reference here http://api-v2-docs.producthunt.c... cc @ossamaweb @jpeguin1 @wayfarerish @raghuv_adhepalli @roy_shao
Knight 
@dhruvparmar thanks for add Goal Create, how about Project Create ? will it be added ?
Dhruv Parmar
@imknight We wouldn't be adding project create as of now. I'll keep you updated here incase something changes.
Rishi
Makerbox for Product Hunt
Dhruv Parmar
API Update: We've added capability to cheer goals via the API. Also GoalType now has `cheer_count` to fetch count of cheers on a Goal. For details check out the the following links: 1. GoalCheer - http://api-v2-docs.producthunt.c... 2. GoalCheerUndo - http://api-v2-docs.producthunt.c... 3. "cheerCount" on GoalType http://api-v2-docs.producthunt.c... cc @wayfarerish
Sarun W.
Screenshot Studio
Screenshot Studio
@wayfarerish @dhruvparmar Any plan for isCheer?
Dhruv Parmar
API Update: 1. Added ability to fetch "votes" on a Post or Comment. Supports filtering votes by "createdBefore" & "createdAfter" params. Results are ordered with newest votes coming first. http://api-v2-docs.producthunt.c... http://api-v2-docs.producthunt.c... 2. Added "userFollow" & "userFollowUndo" mutations. http://api-v2-docs.producthunt.c... http://api-v2-docs.producthunt.c... For further details check out the GraphQL reference here http://api-v2-docs.producthunt.c... cc @janzikan @nikolay_siabrenko
Jan Zikán
Product Hunt Game
Product Hunt Game
@nikolay_siabrenko @dhruvparmar Great job! Would it be possible to provide votes as query? The use case I am thinking of is to trigger an action when a post reaches a certain amount of upvotes. II do not want to track the number of upvotes for a specific post but for all posts - for example show post on a webpage once it reaches 100 upvotes.
Dhruv Parmar
@janzikan hey, we do not plan on exposing "votes" on the root query, as "votes" should always be fetched in the context of a Votable type. For your use case I'd suggest going with something like this 1. Fetch posts ordered by VOTES everyday 2. Filter out posts which could hit the threshold (100 in this case) and trigger polling the "post(id: postId)" field for them. I know this is not ideal, but probably something that could work. Don't worry about the number of requests as we can increase your rate limit quotas if you start getting blocked by them.
Jan Zikán
Product Hunt Game
Product Hunt Game
@dhruvparmar Better solution would be to be able to filter posts that have upvotes count greater than X and to order them by VOTES but in descending order. Are you planning to implement option for ordering so we choose whether the results should be ordered in ascending or descending order? Are you planning to implement filtering for the queries?
Dhruv Parmar
@janzikan the VOTES option sorts posts in descending order of votes count currently. We don't have plans to add filtering for the votes query as of now. Regarding ability to define the sort order, we'll try to incorporate this into the API. I'll share an update here once it's implemented.
Rishi
Makerbox for Product Hunt
@dhruvparmar Hey Dhruv! Would it be safe to assume that grant code and token will be unique for each user? or is is the combination that will be unique? also, when do they change -- on each new sign in/connect?
Dhruv Parmar
@wayfarerish hey, both the code and access token are unique for each user. Currently access tokens are long lived i.e they do not expire. Whenever a user authorises your application you get an access token which you can use to make authenticated requests to the API. Incase you loose the access token you can always re-request it by hitting the "v2/oauth/authorize" endpoint again as most likely the grant code would have expired by then.
Rishi
Makerbox for Product Hunt
Rishi
Makerbox for Product Hunt
@dhruvparmar I see some planned updates to APIs here and see recent changes on github. Will the docs be updated asap or do we need to keep an eye here and on github?
Dhruv Parmar
@wayfarerish hey, any updates to the GraphQL interface of the API will always reflect in the reference here http://api-v2-docs.producthunt.c... Unfortunately we don't have a change-log yet so we've decided to publish those updates here as well for the Makers festival participants.
Rishi
Makerbox for Product Hunt
@dhruvparmar thank you! :)
Rishi
Makerbox for Product Hunt
@dhruvparmar hey again! also is there an issue if the redirect uri is a subdomain? does it have to be a root domain? having issues when it's a subdomain
Dhruv Parmar
@wayfarerish i'm not sure about this, will have to get back to you on this. cc @devladinci
Rishi
Makerbox for Product Hunt
@dhruvparmar Hey Dhruv! What exactly is the use of 'clientMutationId' in goalCreate/Update mutations? It seems to work even if it is null. Are there any examples? Sorry, new to GQL.
Dhruv Parmar
@wayfarerish hey "clientMutationId" is a unique identifier used to track the mutation. In most cases this is not required so you can ignore it. Read more here https://facebook.github.io/relay...
Rishi
Makerbox for Product Hunt
Rishi
Makerbox for Product Hunt
@dhruvparmar hey @dhruvparmar! does the goals API return 20 goals at a time? what is the page size? I sometimes get 19, sometimes 20. Also, how/when does the 'current' flag get set? my first guess was when you add a goal via "Working Now" feature but somehow that feature never works for me so can't test. It always throws a blank page when I click "Join Them" button.
Rishi
Makerbox for Product Hunt
@dhruvparmar thanks, will check that out...then I think it *might* be an edge case bug because I randomly get 19/20 when I have exactly 20 goals 🤔
Dhruv Parmar
@wayfarerish hey, the default page size for all connections is 20. You might be getting 19 if total goals are < 20 (depending on the connection filter params). The 'current' flag is set when a user goes into focus mode for a Goal. You should be able to try that out in the extension here https://chrome.google.com/websto...
Rishi
Makerbox for Product Hunt
@dhruvparmar Hey few questions: 1/ I'm guessing there will be an update to available API endpoints where once can create a "goal" on behalf of a user and view all goals for a user, right? 2/ How do we get Projects and Spaces a user is associated with? Don't see that in User object. 3/What is the significance of 'isMaker' flag in User object? I'm getting false for my profile even though I'm part of Makers on PH 4/ Would updates to Goal/s API include ability to comment on a goal and ability to "cheer". Thanks again :)
Dhruv Parmar
@wayfarerish will try to answer point by point 1. Yes there will be update published here once `GoalCreate` mutation is supported. You can view all goals of a user already by using `userId` filter here http://api-v2-docs.producthunt.c... 2. Currently you can only fetch those for the logged in/authenticated user i.e 'viewer'. Check here for details http://api-v2-docs.producthunt.c... 3. 'isMaker' represents whether the User has been added as a maker for any of the posts on ProductHunt. I think the naming is confusing and we'll probably change the field name soon. 4. As of now ability to comment on a goal and ability to "cheer" are not part of the API plans. We might consider exposing those later on. Again there will be an update published here regarding same.
Rishi
Makerbox for Product Hunt
Charlton Roberts
@dhruvparmar Do the rate limits apply to the entire application or to each user of an application? I'm trying to find the best approach to run some logic as soon as a user completes a certain number of goals. Polling each users' recently completed goals (worried about rate limits)? Polling all goals and parsing for the applicable ones (worried about getting out-of-sync)? Would love to see a webhook for completed goals.
Dhruv Parmar
@charltoons hey, the rate limits apply to the entire application. Unfortunately we do not plan on supporting web-hooks for now. I'd suggest to go with the polling option and you can use "goals" connection to fetch the goals. You could use "userId" & "completed" filters here http://api-v2-docs.producthunt.c... Incase you are getting blocked by rate limits please write to hello@producthunt.com with your API Key and we will bump up the rate limit quota for your application.
Sam Ben
NewsletterStash
NewsletterStash
@dhruvparmar Hey, amazing job on the GraphQL API. Are you guys going to add more fields to the post query? I need the post makers and images also reviews would be great ;)
Arj Singh
@dhruvparmar @ossamaweb Yeah I agree. A link to product videos would be handy too. Hope we can get access to this.
Dhruv Parmar
@ossamaweb @asingh thanks for feedback guys 🙌. We should be able to add those fields to Post query. I'll update here once they are added. Would be good if you could elaborate how you'd be using them in your respective applications?