aroundLatLngViaIP

scope search
type boolean
default false
description

Search for entries around a given location automatically computed from the requester’s IP address.

If you are sending the request from your servers, you must set the X-Forwarded-For HTTP header with the client’s IP address for it to be used as the basis for the computation of the search location.

This parameter will be ignored if used along with insideBoundingBox or insidePolygon

Examples

Search around user’s IP

<?php
/*
'94.228.178.246' should be replaced with the actual IP you would like
to search around. Depending on your stack there are multiple ways to get this
information.
*/
$ip = '94.228.178.246';
$client = new \AlgoliaSearch\Client('YourApplicationID', 'YourSearchOnlyAPIKey');
$client->setExtraHeader('X-Forwarded-For', $ip);

$index = $client->initIndex('index_name');

$results = $index->search('query', [
  'aroundLatLngViaIP' => true
]);
# '94.228.178.246' should be replaced with the actual IP you would like
# to search around. Depending on your stack there are multiple ways to get this
# information.

ip = '94.228.178.246'

client = Algolia::Client.new(application_id: 'YourApplicationID', api_key: 'YourSearchOnlyAPIKey')
client.set_extra_header 'X-Forwarded-For', ip

index = client.init_index 'index_name'

results = index.search('query', {
  aroundLatLngViaIP: true
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
// This is only needed when you're making a request from Node.js. If you make
// your request in the browser, then this is added automatically.
client.setExtraHeader('X-Forwarded-For', '94.228.178.246');

index.search({
  aroundLatLngViaIP: true
}).then(res => {
  // console.log(res);
});
# '94.228.178.246' should be replaced with the actual IP you would like
# to search around. Depending on your stack there are multiple ways to get this
# information.
ip = '94.228.178.246'

client.set_extra_headers('X-Forwarded-For', ip)

results = index.search('query', {
    'aroundLatLngViaIP': True
})
/// '94.228.178.246' should be replaced with the actual IP you would like
/// to search around. Depending on your stack there are multiple ways to get this
/// information.
client.setHeader(withName: "X-Forwarded-For", to: "94.228.178.246")

let query = Query(query: "query")
query.aroundLatLngViaIP = true

index.search(query, completionHandler: { (res, error) in
    print(res)
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.setHeader("X-Forwarded-For", "94.228.178.246")

index.search(new Query("query").setAroundLatLngViaIP(true));
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.SetExtraHeader("X-Forwarded-For", "94.228.178.246");

index.search(
  new Query("query").AroundLatitudeLongitudeViaIP()
);
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.

index.search(
  new Query("query").setAroundLatLngViaIP(true),
  new RequestOptions().addExtraHeader("X-Forwarded-For", "94.228.178.246")
);
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.
client.SetExtraHeader("X-Forwarded-For", "94.228.178.246")

res, err := index.Search("query", algoliasearch.Map{
    "aroundLatLngViaIP": true,
})
// '94.228.178.246' should be replaced with the actual IP you would like
// to search around. Depending on your stack there are multiple ways to get this
// information.

client.execute {
  search into "myIndex" query Query(
    query = Some("query"),
    aroundLatLngViaIP = Some(true)
  ) options RequestsOptions(extraHeaders = Some(Map("X-Forwarded-For" -> "94.228.178.246")))
}
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala