Documentation
Basics
Geocoder is service which provides coordinates for given address. It uses number of sources, among them:
This service searches prepared data for given address and if it doesn't find it, it scrapes and caches the result for future. Right now it covers only following states:
- AK
- AL
- AR
- AZ
- CA
- CO
- CT
- DC
- DE
- FL
- GA
- IA
- ID
- IL
- KS
- LA
- MI
- MN
- MO
- MS
- MT
- NC
- ND
- NH
- NJ
- NM
- NV
- NY
- OH
- OK
- OR
- PA
- RI
- SC
- SD
- TN
- TX
- UT
- VA
- VT
- WA
- WI
- WV
- WY
Authentication.
In order to use this service you need to provide API key among your query or post parameters: key. Ask @asudakov for it in slack.
Methods
Right now service supports only one following method:
geocode - GET /api/geocode
Input parameters:
- q - [mandatory] string, address to geocode
- state - [optional] string, default state if not parsed from "q" parameter
- max_rating - [optional] integer, maximium acceptable rating (the less rating, the better, 0 - the best), default - 0
- scrape - [optional] integer (0 or 1), flag to use scraper if not found in prepared data, it burns API calls, be sure to pass valid queries, default - 0 (not use scraping) WARNING: scraping works in 1 thread only (using lock mechanism). This means whenever different client request something for scraping they are waiting for each other.
Output JSON hash / dictionary / associative array with following keys:
- code - integer, 0 - error, 1 - found result, 2 - not found result according to your query;
- message - string, error description or code message;
- lat - float number, latitude;
- lon - float number, longitude;
- rating - integer number, rating, the less the better, 0 - the best;
- source - string, source of the data.
- source_id - string, identifier in the source.
- address_full - string, prepared full address.
- house_number - string, parsed house number.
- road - string, parsed road.
- zip - string, parsed zip.
- city - string, parsed city.
- county - string, parsed county.
- state - string, parsed state.
- country - string, parsed country.
- id - string, system identifier of the row.
Examples
Get http://vm80:9999/api/geocode?key=ADD_YOUR_KEY_HERE&scrape=0&q=62 ridgeview drive, rochester ny 14617.
Resulting JSON (prettyfied version):
{
"code": 1
,"message": "Geocoded from cache."
,"lat": 43.20241
,"lon": -77.59463
,"rating": 0
,"address_full": "62 ridgeview drive rochester ny us"
,"house_number": "62"
,"road": "ridgeview drive"
,"zip": "14617"
,"city": "rochester"
,"county": "monroe"
,"state": "ny"
,"country": "us"
,"source": "Bing"
,"source_id": ""
,"id": 10880500
}