@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
}
},
Report
@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
}
},
@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.
Report
@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.
@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.
@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.
@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?
@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.
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)
@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.
Report
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()
@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
@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 :)
@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.
Replies
YourStack
YourStack
Bulletin
YourStack
Bulletin
Capture
YourStack
Capture
Bulletin
YourStack
Bulletin
YourStack
Bulletin
YourStack
EasyFinder
YourStack
YourStack
Makerbox for Product Hunt
YourStack
Makerbox for Product Hunt