There is a more direct way to get this from Wikidata, if you want an API. That's the API used by AutoList. Returns JSON or JSONP.
Example query to retrieve all Commons categories within 0.1 kilometer from 40.7576,-73.9857:
http://wdq.wmflabs.org/api?q=claim[373]%20and%20around[625,40.7576,-73.9857,0.1]&props=373
- Live
Explanation of the request:
373
is the property id of the Commons category item
around
takes as arguments: PROPERTY,LATITUDE,LONGITUDE,RADIUS
625
is the property id of the coordinate location item
- The
&props=373
part can be removed if only identifiers are needed
Response:
{
"status": {
"error": "OK",
"items": 8,
"querytime": "1333ms",
"parsed_query": "(CLAIM[373] AND AROUND[625,40.7576,-73.9857,0.1])"
},
"items": [11259, 626926, 659652, 827638, 1756846, 1973105, 3062716, 3363532],
"props": {
"373": [
[1973105, "string", "2010 Times Square car bombing attempt"],
[827638, "string", "Bertelsmann Building"],
[1756846, "string", "Lyceum Theatre (Broadway)"],
[3062716, "string", "Minskoff Theatre"],
[659652, "string", "One Astor Plaza"],
[3363532, "string", "Paramount Building (New York City)"],
[11259, "string", "Times Square"],
[626926, "string", "V-J Day in Times Square (Alfred Eisenstaedt)"]
]
}
}
The server response is rather slow, and seems to increase with the number of categories returned.
See the full documentation.