def get_first_mapbox_geocode_result(query):
 map_id = settings.MAPBOX_MAP_ID
 url = ('http://api.tiles.mapbox.com/v3/%s/geocode/%s.json' % (map_id, query))
 r = requests.get(url)
 r.raise_for_status()
 data = r.json()
 if data.get('results'):
  result = data['results'][0]
  result = dict([(item['type'], item) for item in result])
  return result
 return {}

def get_first_mapbox_geocode_result ( query ) : map_id = settings . MAPBOX_MAP_ID url = ( 'http://api.tiles.mapbox.com/v3/%s/geocode/%s.json' % ( map_id , query ) ) r = requests . get ( url ) r . raise_for_status ( ) data = r . json ( ) if data . get ( 'results' ) : result = data [ 'results' ] [ 0 ] result = dict ( [ ( item [ 'type' ] , item ) for item in result ] ) return result return { }
pass query string as the query to mapbox reverse geocoding api .