|
| 1 | +# Places client |
| 2 | + |
| 3 | +Algolia Places provides a fast, distributed and easy way to use address search. |
| 4 | + |
| 5 | +## Pricing |
| 6 | + |
| 7 | +#### Rate limit |
| 8 | + |
| 9 | +The Algolia Places API enforces 30 queries per second. [Contact us](https://community.algolia.com/places/contact.html) if you need more. |
| 10 | + |
| 11 | +If you're calling the API from your backend, the rate-limits computation is then based on the source IP. |
| 12 | + |
| 13 | +#### Plans |
| 14 | + |
| 15 | +- Free: 1000 requests / day [Sign Up](https://www.algolia.com/users/sign_up/places) |
| 16 | +- Free, with authentication: 100 000 requests / month [Sign Up](https://www.algolia.com/users/sign_up/places) |
| 17 | +- Paying: $0.40 per 1000 requests [Sign Up](https://www.algolia.com/users/sign_up/places) |
| 18 | +- Up to unlimited: [Contact us](https://community.algolia.com/places/contact.html) |
| 19 | + |
| 20 | + |
| 21 | +Visit our [website](https://community.algolia.com/places/pricing.html). |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +#### Unauthenticated |
| 26 | + |
| 27 | +You can use Algolia Places without authentication. Limited to 1000 requests per day. |
| 28 | + |
| 29 | +```kotlin |
| 30 | +val client = ClientPlaces() |
| 31 | +``` |
| 32 | + |
| 33 | +#### Authenticated |
| 34 | + |
| 35 | +Pass an `ApplicationID` and an `APIKey` to the `ClientPlaces` for authenticated usage. |
| 36 | + |
| 37 | +```kotlin |
| 38 | +val client = ClientPlaces( |
| 39 | + ApplicationID("YourApplicationID"), |
| 40 | + APIKey("YourPlacesAPIKey") |
| 41 | +) |
| 42 | +``` |
| 43 | + |
| 44 | +#### Search places for multiple languages |
| 45 | + |
| 46 | +By default, the response of `searchPlaces` contains translations in all languages. |
| 47 | + |
| 48 | +```kotlin |
| 49 | +val response = client.searchPlaces(PlacesQuery("Paris")) |
| 50 | + |
| 51 | +response.hits.first().city.getValue(Language.English) |
| 52 | +``` |
| 53 | + |
| 54 | +#### Search places for one language |
| 55 | + |
| 56 | +However, it is possible to restrict the search results to a single language. |
| 57 | + |
| 58 | +```kotlin |
| 59 | +val response = client.searchPlaces( |
| 60 | + query = PlacesQuery("New-York"), |
| 61 | + language = Language.English |
| 62 | +) |
| 63 | + |
| 64 | +response.hits.first().city |
| 65 | +``` |
| 66 | + |
| 67 | +#### Search places in countries |
| 68 | + |
| 69 | +Unless one or multiple countries are specified, it will search on the whole planet. |
| 70 | + |
| 71 | +```kotlin |
| 72 | +val query = placesQuery("York") { |
| 73 | + countries { |
| 74 | + +UnitedKingdom |
| 75 | + +UnitedStates |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +client.searchPlaces(query) |
| 80 | +``` |
| 81 | + |
| 82 | +#### Search places around radius |
| 83 | + |
| 84 | +Use latitude and longitude coordinates to find places. |
| 85 | + |
| 86 | +```kotlin |
| 87 | +val query = placesQuery { |
| 88 | + aroundLatLng = Point(40.7128f, -74.0060f) // New-York |
| 89 | +} |
| 90 | + |
| 91 | +client.searchPlaces(query) |
| 92 | +``` |
| 93 | + |
| 94 | +#### Reverse geocoding |
| 95 | + |
| 96 | +Reverse geocoding means converting a location (latitude and longitude) to a readable address. |
| 97 | + |
| 98 | +```kotlin |
| 99 | +client.reverseGeocoding(Point(40.7128f, -74.0060f)) // New-York |
| 100 | +``` |
| 101 | + |
| 102 | +#### Get By ObjectID |
| 103 | + |
| 104 | +Use a Places `objectID` to get an Algolia Places record. |
| 105 | + |
| 106 | +```kotlin |
| 107 | + clientPlaces.getByObjectID(ObjectID("201316654_7340078")) // New-York |
| 108 | +``` |
| 109 | + |
0 commit comments