Synchronous Geoip

Both backends with requests or urllib have error handling for connection loss and return code 429 which means that the user has reached the maximum number of requests per min that is 45. Other errors not found should be reported through issues for us to correct.

The tests are simple so they are done with doctest and executed with the pipeline python-package.yml.


The request will be made to the API if for some reason it is not successful and the max_attempts is more than 0 then the attempt will be made again, be aware that this can cause slowness, to cancel this behavior you can set max_attempts to 0.

aiogeoip.requests_geoip.geoip(ip: str, attempts: int = 0, max_attempts: int = 3, time_sleep: int = 2)
  • ip (str) – The IPv4 address you want to geolocation.

  • attempts (int) – Number of attempts that failed to obtain geolocation, do not use directly, it is strictly logical to control this field.

  • max_attempts (int) – Maximum number of retries.

  • time_sleep (int) – Waiting time between failed requests.