Geo Code

Hyperpublic Local Data Engineering Blog
Dec 21

An Introduction to the Hyperpublic API, useful Python tools, and .... NYC Pizza

The following post was written by our newest team member @deland, and it is something between an introduction to the Hyperpublic API and a documentation of a first experience with it. The actual use case described below is just a toy application - but it provided an opportunity for some cool visualizations. We hope you enjoy it and come up with some cool uses of your own!

If you haven't already, the first thing you're going to need to do to get started with the API and follow along (or experiment on your own) is to register for a Hyperpublic API key. It's free! It's fun! There are API wrappers for many programming languages so you can choose your favorite and get started right away. I'm going to be describing my method using Python, but the syntax in all the languages is pretty straightforward.

We're going to focus on pizzerias in New York City because everyone loves pizza (and because we had to choose something). The Hyperpublic API is a window into the world indexed by (exact) location. We can query the API by sending it addresses, zip codes, phone numbers, or latitudes and longitudes as well as categorical information (more on this in a moment). The query we send the API is then resolved to a specific latitude and longitude, and nearby places satisfying the query are returned. This means if we send the API a generic location like "New York, NY", a specific latitude and longitude is set, and then the search is executed. What this really means is you may not get what you wanted if you use such a generic location! The parameters available to query the API are described here, as is the structure of the documents that will be returned to you.

The categorical information in included in the query quite easily. We ask for places with a specific category (restaurant, office, etc) or we can ask for the database to be searched for other text (via the parameter 'q', for query). All locations with a place-name or tag matching your text will be returned. So we will query the API using the location parameter and also q = 'pizza'. For reasons that will become clear soon, I took the result of the queries and stored them in a local Mongo database . To be able to get all pizzarias in new york city, I looped over all the zipcodes in new york. The API only returns 50 locations at a time, but we can ask for more. Here is the relevant code:

 

from hyperpublic import *
...
for zip in zipcodes:
   inserted = 0
   notinserted = 0
   for p in range(1,rounds + 1):
      try:
         items = hp.places.find(location=str(zip),q="pizza", page = p, page_size = 50)
      except:
         break
      for item in items:
         try:
            dbh.nypizza.insert(item, safe = True)
            inserted += 1;
         except DuplicateKeyError:
            notinserted += 1
    print "%d items inserted and %d duplicates found for zipcode %d" % (inserted, notinserted, zip)

Here, my local mongodb connection is called dbh and the collection is called nypizza. Because some zip codes don't cover that much area - many of these queries will return the same pizzerias as other queries. This may not be a problem depending on your application, but you also might want to be aware of it (I just prevented mongo from duplicating records by inserting a key on the id field). Now we have the location of all (I get 2439) pizza places in the city - how easy was that?!

Probably we want to visualize all the locations at once. There are many options for doing this - and many existing python libraries to make our lives easier. For visualization only, my favorite tool (so far) was created by Seth Golub. It creates a heatmap based on density of points, and can overlay the 'heat' on top of maps coming from OpenStreetMap . This image is available under CC-BY-SA.

Pizza

Depending on your needs, you can also overlay this information onto Google Earth maps or Gmaps. The nicest tool I found for this is hosted here. The interface is incredibly easy. Here is the output (it spits out kml data which google earth can read, and can also be accessed by google maps):

Pizza_map
 Let's visualize the network of pizzerias in the city. I inserted a geo index on the mongo database. Then for every pizza place X, I can query the database for all other pizzerias within .1 miles (roughly) of X. Every time I find a relationship like this, I create an edge in a graph using the awesome network/graph software package at NetworkX. Here is the result:

Pizza_graph3

You might start wondering, "if I wanted to go on a 'pizza-slice' tour of new york city, and I wanted the longest sequence of pizzerias separated by .1 miles without visiting any place twice - what would I do?". Coincidentally, I wondered the exact same thing, and wrote a short function to search the graph for the longest such path. (For those who care, finding the longest path in a graph with cycles is known to be NP-hard. So don't try this on your big graphs.) Here is the result, you can visit 32 pizzerias (labeled, in order,it A-Z, then 0-5). Best of luck.

Pizza_tour

Dec 5

We're looking for a super sweet Developer Evangelist

We're looking for an outgoing, technically minded person to represent Hyperpublic in the developer community. You love technology and people. You’ll craft and execute an outreach strategy to get the word out about our platform with developers and companies. Dream up any creative idea and make it happen. You’ll get to work with some of the smartest hackers, designers, and entrepreneurs in the technology startup community.

Responsibilities
  • Advocate for Hyperpublic at meet ups, conferences, hackathons as well as on forums, email, social media etc…
  • Brainstorm great location aware applications and services with developers
  • Write blog posts about apps and web services using location data
  • Listen to the community's needs and ensure that our engineering and product teams are building the right thing
  • Create fun tutorials and example hacks to show off our API
  • Do whatever it takes to make Hyperpublic top of developers’ minds
Requirements
  • Up to speed with current web and mobileapplications
  • Prior experience with community management, developer relations, or software engineering
  • Excellent written, oral, and presentation skills
  • Passionate about the tech industry
  • Leadership experience in a team setting, through hosting events, or building an online community
  • Degree in one or both ends of the creative/technical spectrum: Computer Science (or something similarly technical) or a major focused on writing (such as English Literature)
Preferred
  • Can quickly build a lightweight proof of concept using the Hyperpublic API
  • Prior startup experience, preferably in New York
  • Understand RESTful APIs and the general web stack
  • Programming skills in a modern language like Ruby, Python, and/or Javascript
Interested or can make an introduction? Let us know at jobs@hyperpublic.com. We're also hiring for product designer, data engineers, and front end magicians.

Img_0281

Posted by Jeff Weinstein from New York, NY
Nov 5

Reinvent Local @ General Assembly This Weekend

This weekend General Assembly is hosting the Reinvent Local Hack Day. Hyperpublic, and companies like American Express Open Forum, Yipit, NYC.gov, ordr.in, and more will be presenting tools and services that they've built aimed at helping local businesses connect with their communities. 

If you have any good ideas for applications that you'd like to see built that help you interact with the local businesses around you then swing on by General Assembly, or tweet using the #reinventlocal hashtag, and maybe your idea will come to life this weekend.

 

Screen_shot_2011-11-05_at_10

Nov 4

Ring ring, ring ring. It's you calling Places+

Want to find a place by phone number? Now it’s easy using the Hyperpublic platform. As a developer, you can easily search our Places+ product by phone number.

We built this based on developer requests so please let us know what to build next. Who should you call? Well, whichever company is at 212 229 2217 of course:

You can also query using formatted phone numbers (i.e. with a leading +1, trailing extension, various non-digit characters, etc...) using the same phone_number parameter. Here's the same query using +1 (212) 229 - 2217:

Nov 2

APIs For Beginners @Hyperpublic

On Thursday, November 3rd, Hyperpublic's head of engineering, Doug Petkanics, will be teaching a Skillshare class called "APIs For Beginners." The class will start with the basics, and will cover the following:

  • What is an API?
  • What type of data and services do companies make available via APIs?
  • Why would I use APIs?
  • How do I use APIs?
There is no prior programming experience required, but as APIs are quite literally "programming interfaces", you will have to do some light programming in order to make use of the data you get through the APIs. 

We'll talk about APIs from companies like Flickr, Paypal, Google, and Twitter. You'll learn how to get data from them and what you can do with their services. If you're interested in getting started with building web applications, then this class will provide a good introduction to the types of data and services you can leverage to speed up your development and enhance your applications.

Limited tickets are still available so sign up today. All proceeds from the ticket sales will be donated to HackNY.

Oct 27

Haskell + Hyperpublic = <3

Do you love pure functional programming, strong typing, *and* Hyperpublic's API? Well you're in luck: there is now an official API library for the Haskell language. Check it out on GitHub (https://github.com/mkscrg/hyperpublic-haskell) or Hackage (http://hackage.haskell.org/package/hyperpublic). The docs on Hackage and the source distribution include some example code, and usage questions can be posted to this list.

Let us know what you think!

Oct 3

HackNY Hacks Built on Hyperpublic

This weekend computer science students from schools throughout the entire Northeast descended upon NYU to participate in the HackNY Fall 2011 Hackathon. After 24 hours of coding, students presented what they built. Many of the students used Hyperpublic's Places+ and Geo Deals & Events products to power their hacks. Some of our favorites are listed below.

AdRunner (Winner of 2nd Place Prize)

http://whitepixel.us/adrunner

YPNHOI (Winner of "Most Schools" Prize)

YPNHOI stands for You've Probably Never Heard Of It. This app aims to surface places that aren't being talked about on twitter, that people aren't checking into on Foursquare, and that aren't being reviewed on Yelp. If you've heard of it, it ain't cool.

CheapChap
http://scratch.russfrank.us/

Screen_shot_2011-10-03_at_6

CheapChap helps plan your date in a cost effective way, by recommending cheap gifts, restaurants, and hotels.

Smilify.me
http://smilify.me

Screen_shot_2011-10-03_at_7

Smilify.me takes a photo of you every 5 minutes, and it charts your mood over time. If it determines that you're in a bad mood, it performs an intervention and shows you a picture of a lolcat or suggests that you go to take a walk in a nearby park (discovered through Hyperpublic of course). 

There were many great apps built by some incredibly talented students. We look forward to presenting and participating in many future hackathons.
Oct 1

Fall 2011 HackNY Hackathon

Photo-3

Hyperpublic is proud to be presenting today at the Fall 2011 HackNY Hackathon. HackNY is a non-profit organization in NYC who's aim is to "federate the next generation of hackers for the New York innovation community". Twice per academic year, once in the fall and once in the spring, they bring together undergrad and graduate computer science students from all over the Northeast for a 24-hour hackathon hosted at NYU. 

This year Hyperpublic sponsored a team of 6 students from CMU by transporting them from Pittsburgh and setting them up with lodging, pizza, and caffeine - the staples of any successful weekend hack. We'll be presenting our places database and our deals and events api to the 300+ students who have showed up for the event, and hopefully some cool hacks get built using Hyperpublic data. 

For anyone in attendance, we'll be around for a good portion of the 24-hour hacking period, and we're always reachable at @hyperpublic or at contact@hyperpublic.com.
Posted by Doug Petkanics from NY
Sep 30

Hyperpublic Brings CMU to New York

Two of Hyperpublic's engineers, @ericxtang and @zanecstarr, as well as a couple of our investors and advisors are alums of Carnegie Mellon's computer science program, so we're eager to support CMU students when they're interested in learning about the NYC startup scene. This weekend, about 6 CMU undergrads were looking to make the trip from Pittsburgh to New York in order to participate in a weekend hack event with other local college students. We were going to sponsor their bus tickets, but Eric thought it'd be more fun to get out to Pittsburgh and road trip with the gang. Details of their journey to follow today...

 

6:30am - Rise and Shine

Photo

 

7:30am - Goodbye New York (for a few hours)

Screen_shot_2011-09-30_at_9

 

9:55am - Hello Pittsburgh

(download)
If you see this van on the road, watch out for serious hacking going on inside. In the words of Eric (and Jay-Z), "No chrome on my wheels, but I'm a balla for real!" 

 

11:55am - Arrival at CMU

Photo-2

 

2:55pm - Nap time in the van back to NYC

(download)

 

6:20pm - NYC Pulls into view

Photo-5

 

8:20pm - Donatello's Pizza after a long trip. Totally hits the spot!

Photo_5

 

11:30pm - After a long day of traveling, eating and hanging out, the team retires to the AirBnb apartment in downtown Manhattan.  Rest up for a weekend of hacking!

Airbnb

 

Posted by Doug Petkanics from Bethlehem, PA, Jersey City, NJ and 2 more locations
Sep 29

Geo Deals and Events FAQ

This FAQ answers many of the commonly asked questions about our Geo Deals and Events product. If you have a question that isn't answered here, feel free to email us at affiliates@hyperpublic.com.

What type of data does a call to the deals and events api provide?
This /offers api endpoint returns local daily deals, and local events like concerts and meetups. Let's take a look at one deal example element returned by the API...

Most of the fields are pretty self explanatory. The price field is the cost in dollars of the deal, and the value field is what the deal is presumably worth. The payout field is the amount you will be paid upon each click that your app generates to the url field. The image field is useful for your UI, and the place field gives you location information to plot the deal on a map, or link to a Hyperpublic Places+ place for more information.

How does it work?
After integrating the Geodeals & Events API into your application, Hyperpublic will pay for each click to an offer’s URL. Currently, there is a flat rate per click, but performance-based rates are coming soon.
 
How much do I get paid?
Every deal has a payout field which lists how much a click to that deal is worth. For each click your app generates to the url given in the url field, you will earn the amount given in the payout field.
 
How do I get paid?
You will get paid via check within 45 days of the end of the month if you have earned more than $50. If you require payment early, send us an email to affiliates@hyperpublic.com. When you qualify for payment, Hyperpublic will be in touch to determine where to send your check, so be sure your contact info is correct in your application registration page.
 
When do I get paid?
You’ll be paid by check within 45 days of the end of the month if you’ve earned more than $50. If you require early payment, send an email to affiliates@hyperpublic.com.
 
Can I see how much traffic I’m generating?
Your Application Management page includes a “Click Data” link for each of your applications. Currently, this provides a tabular view of click volume over various time periods and an option to export the data to CSV format. Improvements to this interface are coming soon.
 
Why are the Offers’ URLs so long?
Hyperpublic uses long links to track the traffic your application generates. Each link is unique to the application and the particular offer. Users are redirected to the offer vendor’s page. If you would like to serve shorter links, please use a URL shortener like Bit.ly or Goo.gl.

Some deals and events have a 0.00 payout. What gives?
Many events are free, or do not pass on affiliate fees. This data is still valuable to developers building certain classes of applications so we still include it. If you would like to get paid for every click you generate, only show deals with non-zero payouts. Our developer docs show how to request only deals with non-zero prices.

I am a deals provider. How do I include my deals in Hyperpublic?
Just email us at affiliates@hyperpublic.com. If you have an API or a daily feed containing all the information about the deals you offer, then we're happy to include your data in our product as soon as possible.

How do I get started?
Our developer docs explain how to use our deals product. First you register for an API key, and then you can begin making calls immediately through your web browser, a command line client like CURL, or through one of our API libraries for the language of your choice.

About Geo Code

Geo Code is the engineering blog of Hyperpublic, an open location platform.
Tumblr

Search Blog

Get Updates

Tags

Archive

2011 (27)