producthunt / producthunt-api

Product Hunt API
311 stars 28 forks source link

Pull comments and votes for product 'name' #97

Closed PaulieScanlon closed 8 years ago

PaulieScanlon commented 8 years ago

Hi, whats the best way to make a call to actual product. So if i wanted to get all comments and votes for https://www.producthunt.com/tech/ubeen

The below doesn't work, but that's probably because i'm doing it wrong:

https://api.producthunt.com/v1/posts/all?search[url]=Ubeen'

any ideas?

Cheers!

devladinci commented 8 years ago

Hey @PaulieScanlon

To get product comments you can either: 1) Get details for given post 2) Fetch stream of comments where search[post_id] = POST_ID

About fetching votes - PostVotes

Vlad

PaulieScanlon commented 8 years ago

Hey Vlad thanks for that!

ok so looking up all comments on a post works now: https://api.producthunt.com/v1/comments?search[Ubeen]

The votes thing though, can that work in the same way?

This is wrong: https://api.producthunt.com/v1/posts/1/votes?search[Ubeen] as is this 'https://api.producthunt.com/v1/posts/Ubeen/votes'

What am i missing here?

Cheers!

devladinci commented 8 years ago

@PaulieScanlon https://api.producthunt.com/v1/posts/1/votes?search[Ubeen] should become -> https://api.producthunt.com/v1/posts/__UBEEN_POST_ID__/votes productId is a must for this query :)

Cheers

PaulieScanlon commented 8 years ago

hey, thanks man! so, final question, how would a user know the post id in order to look it up in my app?

devladinci commented 8 years ago

Hm i think you will need 2 queries.

  1. GET product by given name. where you can get the id
  2. GET all votes for product with id

Note: It is assumed, that you should have post id in order to get the details about it. Thats why v1/posts/POSTID/votes and related work with id

Hope this will help. 👍

PaulieScanlon commented 8 years ago

Ok cool, i'll investigate that route! thanks for your help man! very speedy and much appreciated!

Actually, which part of the api should is use to get the product by given name?

this doesn't return anything: https://api.producthunt.com/v1/posts/all?search[url]=https://www.producthunt.com/tech/ubeen

this works: https://api.producthunt.com/v1/posts/all?search[url]=https://www.ubeen.io

but that would require a user to know the URL of the product they wanted to look up.

PaulieScanlon commented 8 years ago

ah, ok don't worry i was missing an '&' https://api.producthunt.com/v1/posts/'+statData.postId+'/votes?newer='+statData.lastVoteId+'&order=asc

You can close this issue now. This one's my bad! :)