API Support
Dhruv Parmar
127 replies
Facing any issues with the API? Share them here
Replies
Sam Ben@ossamaweb
NewsletterStash
@dhruvparmar Thanks for adding makers and media. Any plans on adding reviews query?
Share
YourStack
@ossamaweb we are currently working on internal changes to reviews. They will be added to the API post that.
NewsletterStash
@dhruvparmar Is there a way to know which images are GIFs and which are static from media field?
YourStack
@ossamaweb I'm afraid not and we do not plan to expose that information.
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?
@dhruvparmar would be good if we can filter goals currently in focus mode.
YourStack
@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?
YourStack
@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 ?
YourStack
@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.
@dhruvparmar Got it , i use Viewer to check, is a bit funny, when checking own goal cannot filter by using completed flag
@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 ?
YourStack
YourStack
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
@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.
@dhruvparmar This is great stuff, thanks!
YourStack
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 💻🚀!
YourStack
@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.
@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.
YourStack
@akshay_ashok1 Checkout step 2 here https://github.com/producthunt/p...
@dhruvparmar Amazing job!
@dhruvparmar I can't figure out the client Credential token part
YourStack
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
YourStack
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
@dhruvparmar thanks for add Goal Create, how about Project Create ? will it be added ?
YourStack
Makerbox for Product Hunt
@dhruvparmar thanks! :)
YourStack
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
@wayfarerish @dhruvparmar Any plan for isCheer?
YourStack
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
@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.
YourStack
@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.
@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?
YourStack
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?
YourStack
@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.
Makerbox for Product Hunt
@dhruvparmar thanks :)
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?
YourStack
@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.
Makerbox for Product Hunt
@dhruvparmar thank you! :)
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
YourStack
@wayfarerish i'm not sure about this, will have to get back to you on this. cc @devladinci
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.
YourStack
@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...
Makerbox for Product Hunt
@dhruvparmar thank you!
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.
YourStack
@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...
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 🤔
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 :)
YourStack
@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.
Makerbox for Product Hunt
@dhruvparmar thank you :)
@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.
YourStack
@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.
@producthunt @dhruvparmar Ok sounds good. Thanks!
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 ;)
@dhruvparmar @ossamaweb Yeah I agree. A link to product videos would be handy too. Hope we can get access to this.
YourStack
@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?