Skip to main content
  • Type: boolean
  • Default: false
  • Scope: search
The aroundLatLngViaIP parameter automatically determines a user’s geographic location using their IP address and uses it as the center for geo-based search. This provides location-aware results without requiring explicit coordinates. For more information, or if you want to provide explicit coordinates, see aroundLatLng. To learn more, see Geo location.

Usage

  • For server-side requests, set the X-Forwarded-For header with the user’s IP address. Otherwise, every search will be around the location of your server.
  • You can adjust precision using aroundPrecision, but accuracy varies—especially when IP addresses are mapped to large areas.
  • This parameter is ignored if insideBoundingBox or insidePolygon is used.

Example

Current API clients

// Replace XX.XXX.XXX.XXX with a real IP address.
// How you retrieve this depends on your stack.
var configuration = new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
{
    DefaultHeaders = new Dictionary { { "X-Forwarded-For", "XX.XXX.XXX.XXX" } }
};

SearchClient client = new SearchClient(configuration);

index.Search(new Query("query")
{
    AroundLatLngViaIP = true
});
// Replace XX.XXX.XXX.XXX with a real IP address.
// How you retrieve this depends on your stack.
var configuration = new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
{
    DefaultHeaders = new Dictionary { { "X-Forwarded-For", "XX.XXX.XXX.XXX" } }
};

SearchClient client = new SearchClient(configuration);

index.Search(new Query("query")
{
    AroundLatLngViaIP = true
});
I