Dhruv Parmar

API Support

Facing any issues with the API? Share them here
376 views

Add a comment

Replies

Best
Vaibhav Singh
@dhruvparmar Hi, I am facing a problem with pagination when I query "posts" ordered by votes , where "hasNextPage" field is always false. My query is { posts (order:VOTES, after:"MjA=") { edges{ node{ id name votesCount } } pageInfo { endCursor hasNextPage } } } For this query "hasNextPage" field is always coming as false. Also the order of nodes I am getting is not exactly in order for instance , this is one of the ouputs where post are not in proper descending order. { "node": { "id": "100183", "name": "Feather Icons", "votesCount": 5118 } }, { "node": { "id": "53552", "name": "Carrd", "votesCount": 4723 } }, { "node": { "id": "52794", "name": "Stripe Atlas (Pre-Launch)", "votesCount": 4890 } }, { "node": { "id": "25535", "name": "Startup Launch List", "votesCount": 4890 } }, { "node": { "id": "108401", "name": "Sublime Text 3.0", "votesCount": 5122 } },
Vaibhav Singh
@dhruvparmar Also what I have noticed that not all the products are present in the output, when I use the UI I can see many other products which are missing from the API output. Example "remove.bg" which should be 3rd in terms of votes is not present in the output but "Startup Pitch Decks" is present at 3rd position. { "node": { "id": "14717", "name": "Startup Stash", "votesCount": 18382 } }, { "node": { "id": "76", "name": "Slack", "votesCount": 14591 } }, { "node": { "id": "75048", "name": "Startup Pitch Decks", "votesCount": 9388 } },
Dhruv Parmar
@vaibhav_soulskill hey, we have an existing issue with pagination. Please add "(first: 20)" to the connection params for now. I'll update here once the issue is fixed.
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.
Charlton Roberts
@producthunt @dhruvparmar Ok sounds good. Thanks!
JPEGuin
@dhruvparmar Is there a way to see all maker goals (not just your own ones)? And is there also. way to see goals that are a part of spaces?
Dhruv Parmar
@jpeguin1 We don't have that as of now, but are considering opening it up via `goals` field on the root query. I'll keep you updated here if it's added.
JPEGuin
@dhruvparmar Thanks!
Arjun
@dhruvparmar Are these the only allowed mutations? GoalMarkAsCompleteInput GoalMarkAsIncompleteInput GoalUpdateInput What about creating a goal?
Dhruv Parmar
@arjunz Yes, those are the allowed mutations for now. We are working on adding "GoalCreate". I will update you here once it's added.
Arjun
@dhruvparmar Cool thanks. It doesn't make sense to build an app if it only supported marking goals as done :D
JPEGuin
@dhruvparmar I'm getting "Cannot return null for non-nullable field Collection.coverImage" when attempting to fetch a collection's coverImage. It works fine for Users as that's nullable, but seems like collections have it set to be not nullable where it may actually still return nothing. Any idea on what to do with this one?
Dhruv Parmar
@jpeguin1 that is most likely a bug in the API, do you mind sharing the ID of the collection you are fetching?
JPEGuin
@dhruvparmar I wasn't fetching a single collection. I was fetching all collections with the parameter "first: 10" in an attempt to populate a list of collections.
Dhruv Parmar
@jpeguin1 We've put in a fix for the issue. coverImage should return `null` instead of failing on CollectionType.
JPEGuin
@dhruvparmar That's great, thanks!
Flex.io
Hey @dhruvparmar -- Great to see the v2 starter kit and materials. We're working with python, and are trying to get a basic example up and running with the v2 api using graphql. Question: here's a v1 implementation that queries the posts; what would this look like using the v2 api? import requests auth_token = '' url = 'https://api.producthunt.com/v1/p...' headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + auth_token, 'Host': 'api.producthunt.com' } data = {} response = requests.get(url, headers=headers, data=data)
Dhruv Parmar
@flexiodata thanks for the feedback. these are things that would change for you when querying the v2 API. url = 'https://api.producthunt.com/v2/a...' request_method = 'POST' data = graphql query here I would suggest using a graphql client for python for e.g this one https://github.com/prisma/python... result = client.execute(''' { posts { edges { node { id name tagline } } } } ''') The above query should get you top 20 posts for today on Product Hunt.
Flex.io
Excellent, thanks @dhruvparmar - we're up and running. ... For posterity, here's a complete example should anyone else out there need this (this query will return a list of posts with the id, name, and tagline) import requests import json auth_token = '' url = 'https://api.producthunt.com/v2/a...' headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + auth_token, 'Host': 'api.producthunt.com' } data = { "query": ''' query { posts { edges { node { id name tagline } } } }''' } response = requests.post(url, data=json.dumps(data), headers=headers) content = response.json()
Prashant Nigam
@dhruvparmar Hi Dhruv, Apollo client for iOS or MacOS requires schema.json file of GraphQL server. I tried Apollo CLI to download but was getting 401. Probably missing something. Since this is not user-specific, is it available to download? if yes then please point me to the location. Your help will be much appreciated
Dhruv Parmar
@prashantbuddy hey 👋, we've added schema.json & schema.graphql files to the API repository here. Hope this helps https://github.com/producthunt/p... https://github.com/producthunt/p...
Roy Shao
@dhruvparmar Can we have add goal functionality expose via mutation? I want to be able to create a goal on behave of a user.
Dhruv Parmar
@roy_shao we are currently working on additional write functions including "GoalCreate" and will publish update here once it's added.
Rishi
@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
@dhruvparmar thank you :)
Raghuv Adhepalli
Hi @dhruvparmar. Can we have the youtube url string exposed in "Post" object for all posts that have a youtube video? Thanks !!