17

I am trying to understand argument in package geopy and Nominatim geocoder.

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")

from their documentation.

What User_Agent is and how should I decide what to fill there?

1 Answer 1

13

User_Agent is an http request header that is sent with each request.

Nominatim requires this value to be set to your application name. The goal is to be able to limit the number of requests per application.

https://operations.osmfoundation.org/policies/nominatim/

Provide a valid HTTP Referer or User-Agent identifying the application (stock User-Agents as set by http libraries will not do).

Moreover, should you have a lot of queries, Nominatim asks that the user_agent also contains your email address (or that you use the email parameter)

https://nominatim.org/release-docs/develop/api/Search/

email=< valid email address >

If you are making large numbers of request please include a valid email address or alternatively include your email address as part of the User-Agent string. This information will be kept confidential and only used to contact you in the event of a problem, see Usage Policy for more details.

6
  • Thanks! I have two questions. 1) If I am using GeoPy not as part of any website but just transforming database locally, what kind of http request header should I set. I've put just: "my-application" - is it ok, or should I put something more specific? 2) I cannot find information what does it mean large number of requests. In documentation, it's said that it can process 1 request per second but not the total number. I have roughly 1M address in my db for which I need to find coordinates - is geopy a good approach or should I look for something different? Commented Aug 22, 2018 at 11:29
  • It doesn't matter if it is online or not, the limits still apply. You should put something more specific in order not to be confused with someone else... the easiest would be to put your email, as Nominatim asks. For 2), I don't know.
    – JGH
    Commented Aug 22, 2018 at 11:49
  • For a bulk usage the appropriate thing would be to set up your own Nominatim instance for a virtually unlimited number of requests. The easiest way to get a Nominatim instance up and running is to use Photon with the pre-compiled search index: github.com/komoot/photon
    – egofer
    Commented Oct 2, 2018 at 11:08
  • 1
    Please give an example that shows how we should use the email parameter.
    – Dobedani
    Commented Nov 15, 2018 at 14:59
  • when you create the Nominatim object, just give it your email as an argument. nominatim_service = Nominatim(user_agent='[email protected]') and then call the service on whatever your input data is geolocator = RateLimiter(nominatim_service.geocode, min_delay_seconds=1) collisions['geocodes'] = collisions['location_string'].apply(geolocator) Commented Feb 27, 2020 at 19:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.