Farmers’ Market APIShare This

I love getting my fruit and veggies from my local Farmer’ Market. Unfortunately, as a recent SF transplant I wasn’t sure how to find my local Farmers’ Market. A quick search led me to a USDA website which seemed to contain most of the markets in the country.

Being an open data geek, I looked for an API. Finding none, I decided to make one. To do this, I:

  1. Used the “Export to Excel” function to download the whole dataset.
  2. Cleaned it up in Google Refine; normalized some fields, geocoded some records, added a geojson fields.
  3. Uploaded it to a free couchdb instance.
  4. Added the open source geocouch-utils CouchApp (which gives you a nice map out of the box).

All of this was done in about an hour and at a cost of $0.

So if you’re a developer who also likes fresh fruit & veg, build something on it. I’ll be down on Fillmore.

  • resident_computer_genius

    great work, very impressive knowing how to piece that together

  • http://www.thinkhard-ly.com Yusha Hu

    FYI there’s also a search engine for farmer’s markets and CSAs at http://www.localharvest.org

  • http://www.3scale.net Guillaume

    Really great !! I love the idea!! And fantastic job at putting all that together so fast !!

    You should also check 3scale’s Free Self-Service API Management solution to get analytics, a developer portal and other stuff like that. It just takes a few minutes to sign up for the service and install the plugin.

    http://www.3scale.net

  • http://imperialwicket.com/usda-farmers-markets-to-api-or-not-to-api imperialWicket :: USDA Farmers Markets – To API or not to API

    [...] BackgroundCode For America: Farmers Market APIHacker News CommentaryImpatient? Want the JSON? It's over here.My thoughtsAt first, I thought this was great, and I started thinking about whipping together an Android application that used the API. After putting together a couple of screens and thinking about how little control I had over performance, I started to side strongly with cousin_it from the Hacker News commentary. How large is this data set really? And since any updates are going to need to manually push anyway, what is the benefit in offering the API? Don't read to far into this, I definitely think John's initial work was worthwhile, and it opened my eyes to a useful data set I had not previously endeavored to find. Nonetheless, from a performance a practicallity standpoint (for this data set) – I think a simple JSON object is probably more justified. Also, the map performs terribly, I knew from some experience with the MarkerClusterer (I hadn't touched it since back in the API V2 days) that the performance could be drastically improved with clustering. This was also reaffirmed in the HN Comments (noblethrasher).Stepping backOk, scratch the Android app, what about a map? Easy enough, but without the API, I need the data. I must admit, I admire John's capabilities even more here. It didn't cost me any money, but it sucked away far more than an hour of my life. First, the Excel format download from USDA would not actually load in LibreOffice. I even tried firing up an old Mac that had Office 2008 on it. After 15 minutes of office updates and installation procedures on the old Mac (I apparently had never used Office on it), I found that the downloaded Export.xls file crashed Excel 2008 Mac too. More determined than ever, I threw a handful of sed commands at the file until I had something that looked more like a csv file and less like my cat sitting on my keyboard repeatedly pasting:< /td>< td align='left' valign='top' style='word-wrap:break-word;'>onto the screen. There are a lot of stray line breaks, a few special characters, and who knows what else in there. I also tried to load the original download into Google Refine before manually updating, no luck there either. On that note, I also need to thank John for highlighting Google Refine (and its origin Freebase Gridworks). I was not familiar with the project, and I think I will use it quite a bit.Pretty smooth sailing once I had the Google Refine project loaded. I spent a little time cleaning (not enough), and set about making a rudimentary Google Map page that uses marker clustering. A careful eye will notice that the index.html is suspiciously similar to several of the default Google Maps sample pages.The JSON and a sample MapI did not want to host the json files myself or deal with the API key for the map, so I am just posting the files to my github account. If you pull the files they should run fine API key-less from a localhost environment. Anyone who wants to grab the JSON can then do whatever they want with the data, and not deal with some of the cleanup that I already performed.The index.html file also includes a decent sample of getting the MarkerClusterer set up with InfoWindows too. The code is dirty, and could use some comments, but it is functional. People commented on both codeforamerica and hacker news that localharvest.org does something similar already, though I don't believe they offer the api. Also, their map does not perform all that much better. It is speedier to load, but it fails a little bit on the usability spectrum. Again, in case anyone missed [...]

  • http://pulse.yahoo.com/_GIYFT23775S5JYOBF2YH2652QU ricky c

    Will you update the API in October when new data is available from the USDA?  

  • http://twitter.com/foodfolio Foodfolio

    Love love it. If only we can sync it up with Foodfolio recipes, and find dishes to make with local ingredients. 

  • http://lazyasswasteoid.wordpress.com/2011/08/11/opc/ opc « Unabashed Thoughtcrime
  • Anonymous

    Nice story. FYI the map is unusable on my iPad.

  • http://www.blog.arghh.net/aj/?p=926 pinboard August 13, 2011 — arghh.net

    [...] Farmers’ Market API | Code for America More on Farmer’s Markets from the USDA Open data let @mertonium build a farmer’s market AP I [...]

  • http://blog.apievangelist.com/2011/08/13/united-states-farmers-market-api/ United States Farmers Market API | API Evangelist

    [...] found a story from John Mertens of Code for America, about building a Famers Market API, which I think tells a great story about how anyone with a need, can take a valuable dataset and [...]

  • Vishnu Menon

    Does anyone know what the possible parameters for this api are? is there anything other than Bounding Box? a lat-lon coordinate and a radius would be great.

  • http://www.foodscienceproductdevelopment.com/industry-news/farmers-markets-at-your-fingertips-how-the-community-is-using-our-open-data/ Farmers Markets at Your Fingertips: How the Community is Using Our Open Data | Food Science Chef

    [...] a developer was means to mix his adore of farmers markets and his adore of information into an API for a Farmers Market Directory data.  Tools like this will give developers, tech-savvy foodies, and other information lovers an easier [...]

  • http://codeforamerica.org/2011/08/18/food-nutrition-iconathon-in-los-angeles/ Food & Nutrition Iconathon in Los Angeles | Code for America

    [...] food justice initiatives. (Or additionally, in conjunction with projects like the Code for America Farmer’s Market API or with the Open Food Data Standard [...]

  • http://twitter.com/mathyouwheeler M. Wheeler

    Would you elaborate as to why it is not working on your iPad?

  • http://www.webby-and-wappy.fr/acces/Games/modules.php?name=Forums&file=viewtopic&p=180307#180307 Jon Chung

    abraded wound…

    Thank you for posting this, Its just what I was browsing on bing. Id very much rather hear opinions from an individual, rather than a corporate web page, thats why I like blogs so much. Thanks!. Thank you for posting this, Its just what I was browsing …

  • http://theneighborhoodentrepreneur.com Tolis Dimopoulos

    I love APIs and what you’ve done here, but it has to be maintained to be useful. Will you maintain and support your API?

  • http://codeforamerica.org/2011/09/27/a-data-liberation-walkthrough/ A Data Liberation Walkthrough | Code for America

    [...] time I wrote about how to build a US-wide farmers’ market API in under an hour. Today, I want to walk through a larger challenge to highlight some of the tools [...]

  • http://twitter.com/afinefellow Edward Fine

    I am repeating your steps.  Can you go into more detail about what steps you took in refine?  Could you either enumerate or share your MQL?  Thanks

  • http://www.foodandtechconnect.com/site/2011/10/07/danielle-gould-on-hacking-the-food-system-from-proprietary-to-open-design/ Hacking the Food System: From Proprietary to Open Design | Food+Tech Connect

    [...] like John Mertens at Code for America are developing API’s for USDA data, transforming it into a format others can easily build upon. And these are just a few examples- [...]

  • http://gracelinks.org Jamie Leo
  • http://kkn5k4ta.com 6th

    cargo…

    pages we recommend to see…

  • http://www.one24secrets.com/health-tips/budget-trip-basics control de flotas

    Beneath are tips that may help get you started…

    Decide the approximate prices and prioritize the totally different portions of your journey, equivalent to hotel, airfare, automotive rental, visiting points of interest and sights, food, and gasoline….

  • http://www.businesscardmakeronline.com/ business card maker

    Write Less…

    Give the maximum amount of information with the least amount of words. Time is finite and people are infinitely busy. Blast your knowledge into the reader at the speed of sound….

  • http://howtomake-yourhairgrowfaster.com/ how to make your hair grow faster

    vitamins for the entire community :…

    There are actually plenty of particulars like that to take into consideration. That is a great level to bring up. I offer the ideas above as normal inspiration however clearly there are questions just like the one you carry up the place crucial factor …

  • http://www.scribd.com/acnezine buy acnezine

    Acne can occur due to…

    several factors which include heredity, hormonal changes related to pregnancy. Dermatologists will help you in the treatment for curing acne….

  • http://www.scribd.com/doc/72809740/Acnezine acnezine side effects

    Before bathing…

    apply a mixture of rose water, honey and tomato pulp on your face and allow it be there for twenty to twenty five minutes before washing it….

  • http://www.articleblast.com/Business_and_Management/General/Control_de_flotas_for_a_tension_free_time/ gps control de flota

    And now we come to where religion…

    fits into the picture. The founders knew of this tendency for bureaucracies to put themselves ahead of decency and in the end commit or allow evil as a means of guarding and promoting the bureaucracy. Therefore, they put checks and balances into the co…

  • http://GoArticles.com/article/5611390 gestion de flotas

    Small, but not insignificant,…

    this gesture of active empathy tells much about the man who extended it. He’s a nice guy in a season of nastiness, a trait that may also be his greatest political failing….

  • http://www.articlemonkeys.com/Control-de-flotas-for-a-tension-free-time-359066.html sistema de gestion de vehiculos

    Most automobile rental corporations won’t accept a money deposit…

    Typically, discounted admission charges on area attractions are the most typical and easiest to search out, since many theme parks, museums and other points of interest run specials to draw tourists….

  • http://www.atomox.net/business/control-de-flotas-for-a-tension-free-time.html?preview=1 control de flotas por gps

    The bottom line is to make an informed choice…

    If you wish to go the lower value route while touring, it’s positively a great plan to generate a travel budget….

  • http://www.articledairy.com/control-de-flotas-for-a-tension-free-time/ gestion de flota

    Additionally examine the types of cars…

    Most AAA offices promote discounted tickets for theme parks, museums and other points of interest inside driving distance, and most AAA workplaces sell discounted tickets to fashionable locations just like the Walt Disney World Resort, too….

  • http://www.amazines.com/article_detail.cfm/3505005?articleid=3505005 sistema de gestion de vehiculos

    As stated above, a credit check could also be run…

    To get huge reductions on native attractions, the perfect place to start out is the Web, specifically the web page of no matter attraction you need to visit….

  • http://www.articlepool.com/business-articles/control-de-flotas-for-a-tension-free-time-634066.html control de flota de camiones

    As stated above, a credit check could also be run…

    To get huge reductions on native attractions, the perfect place to start out is the Web, specifically the web page of no matter attraction you need to visit….

  • http://fiverr.com/cipango/give-you-12000-live-scrapebox-links-on-super-low-obl-blog-pages super effective SEO for webmasters

    Hello Admin,…

    You really need quality backlinks, and here’s a cheap and then impressive service – http://fiverr.com/cipango/give-you-12000-live-scrapebox-links-on-super-low-obl-blog-pages ….

  • http://valvoline-oilchangecoupon.blogspot.com/ Valvoline Oil Change Coupon

    Following are some guidelines…

    to write a good post on your blog: Appealing Title; Opine Honestly; Put Link to Resources; Engage in Discussion; Proofread and Copy Edit…

  • http://florida.arrests.org/Arrests/Gary_Moore_4539109/ Garry Moore Venice

    Opine Honestly…

    Put your thoughts and opinions with open heart. Pour out all your thoughts on the topic you are discussing. Your visitors are reading it because they want some good tips, tricks and resources from your post. When visitors are coming to your blog, it’s…

  • http://www.nosehair-trimmer.com/ Nose hair trimmers

    to the village where we will be doing nutritional assessments :…

    Hey sis! I see your having a great time. Miss your lots. Come home fast!…

  • http://amor-en-linea.net/frases-de-amor frases de amor

    Something happened today :…

    Some tips i have observed in terms of personal computer memory is that often there are features such as SDRAM, DDR etc, that must match the requirements of the mother board. If the computer’s motherboard is pretty current while there are no operating-s…

  • http://opthamologists-online.com/ophthalmology ophthalmology

    be a singular problem or it may…

    be combined with other issues. Either way it is possible to replace the lens and eliminate the need to have glasses on when you want to focus on reading anything. Common Eye Irregularities That Can Be Improved with Lens Implants There…

  • http://www.bulkping.com/rss-feed-generator-creator/feed/6822615b2ba3a1ccbbd8821d01d69102.xml government business grants

    this doesn’t mean that calculated risks could…

    not have their proper place. Or that charity could not become a valuable source of stately pride. But the key to recovery might lie in your ability to think of ways to avenge what some people have come to see as…

  • http://www.creativehomemaking.com/frugal_living/half-grocery-bill.shtml Baby Bedding

    to the next step and that is…

    to select the perfect baby crib and bedding for your baby. One of the best ways to search for different types and brands of baby bedding and cribs is through the Web. Because of these technological advancements, we now have the…

  • http://victoria-secretcoupons.com/victorias-secret-coupon-codes Victoria secret coupon codes

    much femininity. You can now get for…

    $29 from its ten $38 price. A woman’s white dress is indeed beautiful, and the ‘Silk-trim Babydoll Dress’ from Victoria’s Secret shows how the brand totally agrees to that. Long-sleeved and embodying an empire-waist design, this white babydoll dres…

  • http://www.nationalrelief.com/DebtResources/DebtReduction.aspx a debt reduction

    Superb website…

    [...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……

  • http://www.nationalrelief.com/DebtResources/MedicalBillsRelief.aspx help with medical

    Great website…

    [...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……

  • http://www.outoftheboxgroupinc.com/ video production costs

    Sites we Like……

    [...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]……

  • http://www.plumberraleighnc.net/plumber-raleigh-nc/five-things-to-consider-when-looking-for-a-raleigh-good-plumber/ plumbers raleigh

    the Special Investigations Unit.[2] [edit] Operations The…

    Plumbers’ first task was the burglary of the office of Daniel Ellsberg’s Los Angeles psychiatrist, Lewis J. Fielding, in an effort to uncover evidence to discredit Ellsberg, who had leaked the Pentagon Papers. The operation was reportedly unsuccessfu…

  • http://chainsawparts.org/ chainsaw parts

    Interesting links…

    [...]%BLOGTITLE%[...]…

  • http://www.outoftheboxgroupinc.com/DRTV-Infomercials infomercial production

    Gems form the internet…

    [...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……

  • http://candybabe.pixnet.net/blog 動畫製作

    Creative videos that you must check out !…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • http://www.bloomshealth.com.au/products/lysine-500/ Lysine Supplement

    than others. The range is the most…

    important thing in the kitchen. It must withstand constant use and still give reliable service at all times. Having a range made of high quality materials makes a lot of difference, no matter what food is being prepared. If a chef…

  • http://MOTELSINMIAMI.ORG motels in miami

    travel…

    [...]we like to honor other sites on the web, even if they aren’t related to us, by linking to them. Below are some sites worth checking out[...]…

  • http://www.carabikinduit.com/adira-asuransi-kendaraan-terbaik-indonesia/ Adira Asuransi Kendaraan Terbaik Indonesia

    marketing members.Car Insurance in Indonesia according to…

    a report in 2011 began much ogled users of motor vehicles, both for cars and motor vehicles, or those who do business rental car and trading in Jakarta. Insurance market continues to expand along with the increase in automotive, while giving…

  • http://ipadstyluspro.com/591/buy-ipad-online-india/ Ipad Stylus Note Taking

    Ipad Stylus…

    [...]all the following are several web links to places which I connect to seeing that we believe these are truly worth browsing[...]…

  • http://www.grandcanyonraftingtrips.org grand canyon rafting trips

    seo blackhat…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]…

  • http://lookzi.com jami

    Awesome.  This is working really well on my geolocation info aggregator, lookzi.com.  Based on the Google Analytics, Farmers’ Markets are more popular than Groupon Deals.  ;)

  • http://www.lmslearningsystem.com/what-is-a-lms-learning-system/ LMS Companies

    Referring Back…

    Today is the time if ever you need to check out a story like this….

  • http://www.dutiee.com/three-opportunities-for-social-innovation-in-2012/ Three Big Opportunities for Social Innovation in 2012 | Dutiee

    [...] and business models around mashups from such public datasets. Check out this great experiment, a Farmers Market API created from a USDA dataset.3. Getting rid of the MiddlemanAround the world, and especially so in [...]

  • http://blog1.dutiee.com/three-opportunities-for-social-innovation-in-2012/ Three Big Opportunities for Social Innovation in 2012

    [...] and business models around mashups from such public datasets. Check out this great experiment, a Farmers Market API created from a USDA [...]

  • Rob O’Donnell

    Would love to use this. With the data be maintained? Nice work!

  • http://lovecares.co.za/index.php?option=com_blog&view=comments&pid=4&Itemid=0 best whey protein for building lean muscle

    audience. blogger needs to make sure that…

    the basic idea of the content is easily understood by human visitors. they should also make sure that the blog is reflected at the top of reputed search engines. it is also important to note that; search engines need some time…

  • http://iconathon.wordpress.com/2012/06/06/iconathon-la-food-nutrition/ Iconathon LA: Food & Nutrition « Iconathon

    [...] food justice initiatives. (For example, in conjunction with projects like the Code for America Farmer’s Market API or with the Open Food Data Standard [...]

  • http://iconathon.wordpress.com/2011/08/16/iconathon-la-food-nutrition/ Iconathon LA: Food and Nutrition « Iconathon

    [...] food justice initiatives. (For example, in conjunction with projects like the Code for America Farmer’s Market API or with the Open Food Data Standard [...]

  • http://hightsh.org/tsh-symptoms/tsh-symptoms tsh symptoms

    Evike.com…

    Evike | Buy Airosft Scopes and Airsoft Lenses…

  • http://www.merchantcircle.com/business/Brown.And.Crouppen.Law.Firm.P.C..816-559-8777 medical malpractice lawyer missouri

    article on codeforamerica.org…

    article on codeforamerica.org read more…

  • Sean Gregory

    Was it not possible to retain or use the schedule data for the markets? it would be really nice to get results based on availablity

John Mertens 2011 Fellow

John is a full stack developer with an emphasis on rapid prototyping and data wrangling.
@mertonium | Bio & Posts