code: def osm_polygon_download(query, limit=1, polygon_geojson=1):
      
      # define the parameters
      params = OrderedDict()
      params['format'] = 'json'
      params['limit'] = limit
      params['dedupe'] = 0 #this prevents OSM from de-duping results so we're guaranteed to get precisely 'limit' number of results
      params['polygon_geojson'] = polygon_geojson
  
      # add the structured query dict (if provided) to params, otherwise query
      # with place name string
      if isinstance(query, str):
          params['q'] = query
      elif isinstance(query, dict):
          # add the query keys in alphabetical order so the URL is the same string
          # each time, for caching purposes
          for key in sorted(list(query.keys())):
              params[key] = query[key]
      else:
          raise TypeError('query must be a dict or a string')
  
      # request the URL, return the JSON
      response_json = nominatim_request(params=params, timeout=30)
      return response_json
docs: Geocode a place and download its boundary geometry from OSM's Nominatim API.
  
      Parameters
      ----------
      query : string or dict
          query string or structured query dict to geocode/download
      limit : int
          max number of results to return
      polygon_geojson : int
          request the boundary geometry polygon from the API, 0=no, 1=yes
  
      Returns
      -------
      dict