Yahoo! Local is pretty awesome; it can tell you all the stores named “Shaw’s” near the zip code 02215, for example. Yahoo! Local’s API, however, gives different results depending on its mood— sometimes the Shaw’s in 02215 is returned second; sometimes fifth; sometimes not at all.
Try this URL instead: http://api.maps.yahoo.com/ajax/locsrch
It takes these parameters:
appid is your application ID. If you use the Yahoo! APIs, you have one.
ll is the latitude and longitude, with a | (pipe) between them. Encoded, the | is %7C ; remember this if you are using Ruby’s URI.parse, for example.
t is 1; 1 means local search.
q is the query. It may only contain these characters, so delete the rest: [a-zA-Z0-9_.-]
r is the radius in miles.
n is the number of items to return. There’s probably an upper bound, somewhere around 20.
This produces JavaScript which can be evaled. In Ruby, you can do this instead (let javascript be the result of calling this URL):
require 'json'
if javascript =~ /\\\\((.*),.*,.*\\\\);/
json = $1
results = JSON.parse(json)
items = results['ITEMS']
end
Now items is an array of hashes with at least these keys as strings: CITY, LATITUDE, LONGITUDE, STATE, ADDRESS, TITLE. No ZIP, though.