A Python library to use the what3words REST API.
The what3words PHP library gives you programmatic access to convert a 3 word address to coordinates (forward geocoding), to convert coordinates to a 3 word address (reverse geocoding), and to determine the currently support 3 word address languages.
To use this library you’ll need a what3words API key, which can be signed up for here.
To install what3words, simply:
$ pip install what3words
Installing the latest version from Github:
$ git clone https://github.com/what3words/w3w-python-wrapper.git
$ cd w3w-python-wrapper
$ python setup.py install
This function takes the words parameter as either:
- a string of 3 words
'table.book.chair'
- an array of 3 words
['table', 'book', 'chair']
This function takes the latitude and longitude:
- 2 parameters:
lat=0.1234
,lng=1.5678
This function returns all available languages
>>> import what3words
>>> w3w = what3words.Geocoder(api_key='YOUR-API-KEY')
>>> res = w3w.position(words='prom.cape.pump')
>>> print(res)
>>> import what3words
>>> w3w = what3words.Geocoder(api_key='YOUR-API-KEY')
>>> res = w3w.words(lat='51.484463', lng='-0.195405')
>>> print(res)