Skip to content

Latest commit

 

History

History
109 lines (70 loc) · 2.52 KB

Places.md

File metadata and controls

109 lines (70 loc) · 2.52 KB

Places client

Algolia Places provides a fast, distributed and easy way to use address search.

Pricing

Rate limit

The Algolia Places API enforces 30 queries per second. Contact us if you need more.

If you're calling the API from your backend, the rate-limits computation is then based on the source IP.

Plans

  • Free: 1000 requests / day Sign Up
  • Free, with authentication: 100 000 requests / month Sign Up
  • Paying: $0.40 per 1000 requests Sign Up
  • Up to unlimited: Contact us

Visit our website.

Usage

Unauthenticated

You can use Algolia Places without authentication. Limited to 1000 requests per day.

val client = ClientPlaces()

Authenticated

Pass an ApplicationID and an APIKey to the ClientPlaces for authenticated usage.

val client = ClientPlaces(
    ApplicationID("YourApplicationID"),
    APIKey("YourPlacesAPIKey")
)

Search places for multiple languages

By default, the response of searchPlaces contains translations in all languages.

val response = client.searchPlaces(PlacesQuery("Paris"))

response.hits.first().city.getValue(Language.English)

Search places for one language

However, it is possible to restrict the search results to a single language.

val response = client.searchPlaces(
    query = PlacesQuery("New-York"),
    language = Language.English
)

response.hits.first().city

Search places in countries

Unless one or multiple countries are specified, it will search on the whole planet.

val query = placesQuery("York") {
    countries {
        +UnitedKingdom
        +UnitedStates
    }
}

client.searchPlaces(query)

Search places around radius

Use latitude and longitude coordinates to find places.

val query = placesQuery {
    aroundLatLng = Point(40.7128f, -74.0060f) // New-York
}

client.searchPlaces(query)

Reverse geocoding

Reverse geocoding means converting a location (latitude and longitude) to a readable address.

client.reverseGeocoding(Point(40.7128f, -74.0060f)) // New-York

Get By ObjectID

Use a Places objectID to get an Algolia Places record.

 clientPlaces.getByObjectID(ObjectID("201316654_7340078")) // New-York