> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/ja/search/llms.txt)

# Search by Text

The Place Autocomplete returns place suggestions in response to user search queries, such as addresses, businesses and POIs. The Place Autocomplete will help you to implement such functionality in a few lines of code.

## User experience

This use case allows users quickly search for a place by its name, results can be limited to a region and sorted by proximity.

  

Your browser doesn't support HTML5 video. Open [link to the video](https://docs.mapbox.com/android/ja/android/ja/assets/medias/search-place-autocomplete-demo-a6993f677b4dd90deac25a47aae6a4b9.mp4).

We have a [ready-made sample app](https://github.com/mapbox/mapbox-search-android/blob/main/MapboxSearch/sample/src/main/java/com/mapbox/search/sample/) that you can try in Android Studio with Place Autocomplete and other scenarios. We encourage you to install and try it for yourself.

> **Related content (example): [Full example of Place Autocomplete integration](https://docs.mapbox.com/android/ja/search/examples/place-autocomplete/)**
> 
> Learn how to integrate the Place Autocomplete with Maps SDK and Search UI components in a sample app.

## Integration

Place Autocomplete provides coroutine-based API. In the following integration steps, we assume that you are familiar with the Kotlin coroutines and your Android project has `Kotlin-ktx` dependencies added. See the [Kotlin coroutines guide](https://developer.android.com/topic/libraries/architecture/coroutines) for more information.

> **Related content (guide): [Installation guide](https://docs.mapbox.com/android/ja/search/guides/install/)**
> 
> Before using any of Mapbox's Search products, you need to do some common installation steps. Follow this guide to complete installation, then continue with the steps below.

1.  The main entrypoint class is called `PlaceAutocomplete`, you will need to instantiate this class first:

```kotlin
val placeAutocomplete = PlaceAutocomplete.create(mapboxAccessToken)
```

2.  Retrieve autocomplete suggestions using [`suggestions()`](https://docs.mapbox.com/android/search/api/place-autocomplete/2.28.2/place-autocomplete/com.mapbox.search.autocomplete/-place-autocomplete/suggestions.html) function. As described above, Place Autocomplete provides coroutine-based API, and `suggestions()` is a suspend function which [should be called only from a coroutine or another suspend function](https://developer.android.com/topic/libraries/architecture/coroutines). The following code assumes it was called from the activity's `lifecycleScope`:

```kotlin
lifecycleScope.launchWhenCreated {
    val response = placeAutocomplete.suggestions(query = "Washington DC")
}
```

3.  Process the Place Autocomplete response. The suggestions() function returns either error or suggestions list:

```kotlin
response.onValue { suggestions: List<PlaceAutocompleteSuggestion> ->
    processSuggestions(suggestions)
}.onError { e ->
    // process error
}
```

4.  When a user has selected a suggestion, call [`select()`](https://docs.mapbox.com/android/search/api/place-autocomplete/2.28.2/place-autocomplete/com.mapbox.search.autocomplete/-place-autocomplete/select.html). This function returns a `PlaceAutocompleteResult` object that provides detailed information about the place. Calling `select()` also ends your billing session, so you must call it whenever the user selects a suggestion.

```kotlin
val selectedSuggestion = pickSuggestion(suggestions)

val selectionResponse = placeAutocomplete.select(selectedSuggestion)
selectionResponse.onValue { result ->
    // process result
}.onError { e ->
    // process error
}
```

> **Related content (glossary): [API Reference](https://docs.mapbox.com/android/ja/search/api-reference/)**
> 
> For more information, see the full API reference for the Place Autocomplete for Android.

## Search by Text Pricing

There is no separate charge if you choose to use Mapbox Search SDK for Android to access our APIs, you only pay by the Search API usage.

Usage of the Search by Text is measured in monthly API sessions. Details about the number of API requests included in the free tier and the cost per request beyond what is included in the free tier are available on the [pricing page](https://www.mapbox.com/pricing/#search-api-session).