Once the event started, the (optional) theme was announced: Make a game with Laravel.

Games are tough, much tougher than most people expect, and since I knew my time was going to be limited, I decided to build something else instead.

The Idea

As mobile applications gained popularity, the problem of getting people to pay for these applications was a discussed a lot.

Developers would often mumble:

“you’ll spend $4 on a cup of coffee at (insert your favorite coffee brand here, usually Starbucks), why won’t you spend a paltry $1 on my app?”

As I purchased a cup of coffee on my train ride down to NYC this past Friday it got me to thinking about the quote above. The $4 price mentioned is usually for a fancy high end blend, and even factoring in high San Francisco prices I knew I was paying far less than $4.

Photo by wu yi on Unsplash

What is the average price of a cup of coffee across the country?

The Plan

I had put the question out of my mind, until I was trying to decide what to build for LaraHack.

The idea was simple, but just how would I be able to work out the average price of a cup of coffee from all over the country? Although it might be fun to travel all over the country buying coffee, I’m pretty sure my budget wouldn’t extend much further than my local coffee shop.

I searched Google, and while there were some news posts about the price of coffee there was no data that I could use. One article did catch my eye:

https://www.usnews.com/news/blogs/data-mine/2015/09/29/americans-pay-an-average-270-for-coffee-while-tipping-20-percent

The article had a very cool infographic…

Right there was the data that confirmed my suspicion, none of the coffee options where over $4. But this was a just a one time snapshot, and I wanted something that would be updated on a regular basis. The data was sourced from Square purchases. I doubted they would give me access to their data.

This got me thinking about where else I could get this information. I started to think about online ordering. Grubhub jumped to mind, you can order from lots of different restaurants from all over the country, surely coffee was on the menu too. Unfortunately I was unable to be find a public API, and although a private one appears to exists, I doubted I’d be able to get access for this idea, and even if I could not in time for the hackathon.

I continued to think about menus, and after some more searching landed on Foursquare. Not only would their API allow me to search for cafes from all over the countries, their API would also allow me to inspect the menus for some of these cafes too, which often includes pricing. Not every venue on Foursquare has a menu online, but I’d could get enough data to build what I wanted, and I could signup and start developing right away.

The Build

Clearly I would be building the website in Laravel, and to make things easy on myself, deployed to servers managed with Forge on Digitalocean.

I found a Laravel package for interfacing with Foursquare:

I built a few small pages that let me search Foursquare specifically for cafes, and view their menus, and find those that contained coffee as an option that listed the price.

Once I found a match I added that cafe to the website database.

I then wrote a Laravel command to query Foursquare on a regular basis to save the price of the coffee for each cafe to the local database.

Once I had a list of prices for coffee I was able to calculate the average.