Javascript Api

6 views
Skip to first unread message

Lukas Mairl

unread,
Oct 6, 2011, 5:03:44 PM10/6/11
to Hyperpublic API Developers
Hi,
i started playing around with the api. I'm doing some simple queries.
im wondering why i only get ONE result back.

var client = new Hyperpublic('key', 'key');
var result = client.places.find({ "location" : "New York, NY",
"q":"five guys burger", limit:10}, 'result');

function result(result) {
console.log(result);
}

thanks

Lukas




Doug Petkanics

unread,
Oct 6, 2011, 5:25:06 PM10/6/11
to hyperpublic-a...@googlegroups.com
Hi Lukas,

The expected response is an array with 0-10 results. I tried the call
you gave below and got an array with 2 results. The way that the
"location" param works is that it geocodes the string you pass in to a
lat/lon and then runs a query with the default radius (2km) around
that lat/lon.

I tried passing in an additional param - "radius":10, and got more
results. You can also pass a "limit":50 to get up to 50 results in one
call.

Let me know if you run into any additional problems.

-Doug
do...@hyperpublic.com

--
Doug Petkanics | @petkanics
Co-founder at Hyperpublic

Lukas Mairl

unread,
Oct 6, 2011, 5:49:33 PM10/6/11
to Hyperpublic API Developers
Hi,
thanks for your quick reply.
expanding the radius and limit works, but is there a way to be more
specific regarding results?

for example i would like to get results limited to "New York City" and
"Restaurants"

thanks

Lukas








On Oct 6, 5:25 pm, Doug Petkanics <d...@hyperpublic.com> wrote:
> Hi Lukas,
>
> The expected response is an array with 0-10 results. I tried the call
> you gave below and got an array with 2 results. The way that the
> "location" param works is that it geocodes the string you pass in to a
> lat/lon and then runs a query with the default radius (2km) around
> that lat/lon.
>
> I tried passing in an additional param - "radius":10, and got more
> results. You can also pass a "limit":50 to get up to 50 results in one
> call.
>
> Let me know if you run into any additional problems.
>
> -Doug
> d...@hyperpublic.com

Doug Petkanics

unread,
Oct 6, 2011, 5:54:17 PM10/6/11
to hyperpublic-a...@googlegroups.com
We do not currently have a way to restrict queries to everything
within a given city so you'll have to use the radius params and filter
on your side for things that don't apply.

For the example you gave I'd run a query like:
location=New York, NY,
radius=20,
category=Food,
limit=50

-Doug

Lukas Mairl

unread,
Oct 6, 2011, 6:06:31 PM10/6/11
to Hyperpublic API Developers
Sounds good. Thanks for your help

Lukas Mairl

unread,
Nov 16, 2011, 11:53:02 AM11/16/11
to Hyperpublic API Developers
Hi,
im still having issues with getting correct results for a lot of
queries.

here is another example:
hyperpublic.places.find({ "location" : "New York, NY", "radius":50,
"q":"serendipidy 3", "limit": "50"}, 'log');

this query gives me all sorts of results, but i'm looking for the
"restaurant", "serendipidy 3" in "new york" city.
is there a way to make the search more accurate?


i basically want to restrict search results to restaurants only. after
looking at the category list i think the main category for restaurants
would be
"Entertainment","id":"4e28ae8a643bce0004000060"} ?

thanks

Doug Petkanics

unread,
Nov 16, 2011, 1:46:12 PM11/16/11
to hyperpublic-a...@googlegroups.com
Hey Lukas,

You can query by the food or restaurant categories which will help a bit, but the root of the problem is that our API returns results ordered by proximity to the passed in location. In the case of your example location: New York, NY, it's geocoding to a lat/lon somewhere in lower Manhattan, and ordering all matches based upon how close they are to that point. 

To get more accurate you can pass a more granular location like an address or a postal code. If you know the phone # of the business you can pass it to get an exact match. 

You're not the only one who has expressed that they'd rather have their results ordered by relevance instead of distance. We're working on releasing new endpoints/parameters which will support this, and we'll definitely announce on this list when we do.

-Doug

Reply all
Reply to author
Forward
0 new messages