This library allows developers to easily interact with the Hyperpublic API with Node.js. It is intended to be simple and somewhat flexible. Each method requires two parameters: your query and a callback function. API keys are always required and can be created/retrieved at here.
npm install hyperpublic
First, we must always include our API keys.
var clientId = 'YOUR_CLIENT_ID'; var clientSecret = 'YOUR_CLIENT_SECRET_KEY';
Then, we must create the Hyperpublic object that you will query against.
var api = new hyperpublic.API(client_id, client_secret);
Lastly, we will ask Hyperpublic for something. How about all the pizza places near the Hyperpublic Office?
api.places.find({ "q" : "pizza", "location" : "416 W 13th St, New York, NY 10014", "radius" : "5" }, function (pizza_places) { for (i = 0, len = pizza_places.length; i < len; i++) { if (pizza_places[i].display_name && pizza_places[i].locations[0] !== undefined) { console.log(pizza_places[i].display_name + ' - ' + pizza_places[i].locations[0].name ); } } });
For more information and detailed documentation on the Hyperpublic API, check out our developer resources.