diff --git a/README.md b/README.md index 235e04d..4e6dfed 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,20 @@ Installation pip install mapq +Settings +-------- + +The easiest way to use `mapq` is by setting the `MAPQUEST_API_KEY` +environment variable in your local environment. + + export MAPQUEST_API_KEY="my_api_key" + + Usage ----- +There are two ways of interacting with `mapq`'s API. + ```python >>> from mapq import Geo >>> g = Geo('my_api_key') @@ -29,3 +40,23 @@ Usage >>> g.latlng('155 9th St San Francisco, CA') {'lat': 37.775002, 'lng': -122.418297} ``` + +You can also use the Mapquest API without interacting with the `Geo` +class. + + +```python +>>> import mapq + +>>> mapq.address('155 9th St San Francisco, CA') +[{'lots': {'of': 'results'}}, ...] + +>>> mapq.batch('94103', '1 Infinity Loop Cupertino, CA') +[{'multiple': 'locations'}, ...] + +>>> mapq.reverse(37.775002, -122.418297) +{'looks': {'like': '155 9th St'}} + +>>> mapq.latlng('155 9th St San Francisco, CA') +{'lat': 37.775002, 'lng': -122.418297} +``` diff --git a/mapq/__init__.py b/mapq/__init__.py index 7379c1d..c8e0738 100644 --- a/mapq/__init__.py +++ b/mapq/__init__.py @@ -1 +1,2 @@ +from .core import address, batch, latlng, reverse from .geo import Geo diff --git a/mapq/core.py b/mapq/core.py new file mode 100644 index 0000000..ca4989d --- /dev/null +++ b/mapq/core.py @@ -0,0 +1,25 @@ +""" +Simplified methods for calling Mapquest's Geocoding API. +""" + +from .geo import Geo + + +def address(name): + """Geocode an address.""" + return Geo().address(name) + + +def batch(*locations): + """Batch geocode multiple addresses.""" + return Geo().batch(*locations) + + +def latlng(address): + """Get the latitude and longitude coordinates for an address.""" + return Geo().latlng(address) + + +def reverse(lat, lng): + """Reverse geocode lat/lng coordinates.""" + return Geo().reverse(lat, lng)