Skip to main content

Module geolocator

Module geolocator 

Source
Expand description

Geolocation service

This global module can be used to provide geolocation information to blocks that support it.

ipapi.co is the default geolocator service.

§Configuration

§Common Options

KeyValuesRequiredDefault
rate_limit_intervalSeconds to wait before contacting the service again after it reported rate limiting. Until then, cached results are served and no new requests are made.No600

§ipapi.co Options

KeyValuesRequiredDefault
geolocatoripapiYesNone

§Ip2Location.io Options

KeyValuesRequiredDefault
geolocatorip2locationYesNone
api_keyYour Ip2Location.io API key.NoNone

An api key is not required to get back basic information from ip2location.io. However, to get more additional information, an api key is required. See pricing for more information.

The api_key option can be omitted from configuration, in which case it can be provided in the environment variable IP2LOCATION_API_KEY

§Examples

Use the default geolocator service:

[geolocator]
geolocator = "ipapi"

Use Ip2Location.io

[geolocator]
geolocator = "ip2location"
api_key = "XXX"

Structs§

Geolocator
GeolocatorConfig
IPAddressInfo
RateLimited
Error cause set by backends when the service refuses to answer because of rate limiting. Callers can detect it with is_rate_limited and back off instead of retrying, which would only prolong the block.

Enums§

GeolocatorBackend

Functions§

is_rate_limited