Skip to content

autocomplete async

autocomplete(
    query_text: SensitiveString,
    *,
    config_overrides: Optional[AsyncGeoPlacesClientConfig] = None,
    max_results: Optional[int] = None,
    bias_position: Optional[Position] = None,
    filter: Optional[AutocompleteFilter] = None,
    postal_code_mode: Optional[PostalCodeMode] = None,
    additional_features: Optional[AutocompleteAdditionalFeatureList] = None,
    language: Optional[LanguageTag] = None,
    political_view: Optional[CountryCode] = None,
    intended_use: Optional[AutocompleteIntendedUse] = None,
    key: Optional[ApiKey] = None,
) -> AutocompleteResponse

Autocomplete completes potential places and addresses as the user types, based on the partial input. The API enhances the efficiency and accuracy of address by completing query based on a few entered keystrokes. It helps you by completing partial queries with valid address completion. Also, the API supports the filtering of results based on geographic location, country, or specific place types, and can be tailored using optional parameters like language and political views. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

For more information, see Autocomplete in the Amazon Location Service Developer Guide.

Parameters:

  • query_text (SensitiveString) –

    The free-form text query to match addresses against. This is usually a partially typed address from an end user in an address box or form.

    The fields QueryText, and QueryID are mutually exclusive.

  • max_results (Optional[int], default: None ) –

    An optional limit for the number of results returned in a single call.

    Default value: 5

  • bias_position (Optional[Position], default: None ) –

    The position in longitude and latitude that the results should be close to. Typically, place results returned are ranked higher the closer they are to this position. Stored in [lng, lat] and in the WGS 84 format.

    The fields BiasPosition, FilterBoundingBox, and FilterCircle are mutually exclusive.

  • filter (Optional[AutocompleteFilter], default: None ) –

    A structure which contains a set of inclusion/exclusion properties that results must possess in order to be returned as a result.

  • postal_code_mode (Optional[PostalCodeMode], default: None ) –

    The PostalCodeMode affects how postal code results are returned. If a postal code spans multiple localities and this value is empty, partial district or locality information may be returned under a single postal code result entry. If it's populated with the value EnumerateSpannedLocalities, all cities in that postal code are returned. If it's populated with the value EnumerateSpannedDistricts, all combinations of the postal code with the corresponding district and city names are returned.

  • additional_features (Optional[AutocompleteAdditionalFeatureList], default: None ) –

    A list of optional additional parameters that can be requested for each result.

  • language (Optional[LanguageTag], default: None ) –

    A list of BCP 47 compliant language codes for the results to be rendered in. If there is no data for the result in the requested language, data will be returned in the default language for the entry.

  • political_view (Optional[CountryCode], default: None ) –

    The alpha-2 or alpha-3 character code for the political view of a country. The political view applies to the results of the request to represent unresolved territorial claims through the point of view of the specified country.

    The following political views are currently supported:

    • ARG: Argentina's view on the Southern Patagonian Ice Field and Tierra Del Fuego, including the Falkland Islands, South Georgia, and South Sandwich Islands

    • EGY: Egypt's view on Bir Tawil

    • IND: India's view on Gilgit-Baltistan

    • KEN: Kenya's view on the Ilemi Triangle

    • MAR: Morocco's view on Western Sahara

    • RUS: Russia's view on Crimea

    • SDN: Sudan's view on the Halaib Triangle

    • SRB: Serbia's view on Kosovo, Vukovar, and Sarengrad Islands

    • SUR: Suriname's view on the Courantyne Headwaters and Lawa Headwaters

    • SYR: Syria's view on the Golan Heights

    • TUR: Turkey's view on Cyprus and Northern Cyprus

    • TZA: Tanzania's view on Lake Malawi

    • URY: Uruguay's view on Rincon de Artigas

    • VNM: Vietnam's view on the Paracel Islands and Spratly Islands

  • intended_use (Optional[AutocompleteIntendedUse], default: None ) –

    Indicates if the query results will be persisted in customer infrastructure. Defaults to SingleUse (not stored). Currently, Autocomplete does not support storage of results.

  • key (Optional[ApiKey], default: None ) –

    Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

Raises:

Source code in docs_src/capo_geo_places/_services/async_geo_places.py
async def autocomplete(
    self,
    query_text: "capo_geo_places.types.sensitive_string.SensitiveString",
    *,
    config_overrides: Optional[AsyncGeoPlacesClientConfig] = None,
    max_results: Optional[int] = None,
    bias_position: Optional["capo_geo_places.types.position.Position"] = None,
    filter: Optional[
        "capo_geo_places.types.autocomplete_filter.AutocompleteFilter"
    ] = None,
    postal_code_mode: Optional[
        "capo_geo_places.types.postal_code_mode.PostalCodeMode"
    ] = None,
    additional_features: Optional[
        "capo_geo_places.types.autocomplete_additional_feature_list.AutocompleteAdditionalFeatureList"
    ] = None,
    language: Optional["capo_geo_places.types.language_tag.LanguageTag"] = None,
    political_view: Optional[
        "capo_geo_places.types.country_code.CountryCode"
    ] = None,
    intended_use: Optional[
        "capo_geo_places.types.autocomplete_intended_use.AutocompleteIntendedUse"
    ] = None,
    key: Optional["capo_geo_places.types.api_key.ApiKey"] = None,
) -> "capo_geo_places.types.autocomplete_response.AutocompleteResponse":
    """<p> <code>Autocomplete</code> completes potential places and addresses as the user types, based on the partial input. The API enhances the efficiency and accuracy of address by completing query based on a few entered keystrokes. It helps you by completing partial queries with valid address completion. Also, the API supports the filtering of results based on geographic location, country, or specific place types, and can be tailored using optional parameters like language and political views. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/autocomplete.html">Autocomplete</a> in the <i>Amazon Location Service Developer Guide</i>.</p>

    Args:
        query_text: <p>The free-form text query to match addresses against. This is usually a partially typed address from an end user in an address box or form.</p> <note> <p>The fields <code>QueryText</code>, and <code>QueryID</code> are mutually exclusive.</p> </note>
        max_results: <p>An optional limit for the number of results returned in a single call.</p> <p>Default value: 5</p>
        bias_position: <p>The position in longitude and latitude that the results should be close to. Typically, place results returned are ranked higher the closer they are to this position. Stored in <code>[lng, lat]</code> and in the WGS 84 format.</p> <note> <p>The fields <code>BiasPosition</code>, <code>FilterBoundingBox</code>, and <code>FilterCircle</code> are mutually exclusive.</p> </note>
        filter: <p>A structure which contains a set of inclusion/exclusion properties that results must possess in order to be returned as a result.</p>
        postal_code_mode: <p>The <code>PostalCodeMode</code> affects how postal code results are returned. If a postal code spans multiple localities and this value is empty, partial district or locality information may be returned under a single postal code result entry. If it's populated with the value <code>EnumerateSpannedLocalities</code>, all cities in that postal code are returned. If it's populated with the value <code>EnumerateSpannedDistricts</code>, all combinations of the postal code with the corresponding district and city names are returned.</p>
        additional_features: <p>A list of optional additional parameters that can be requested for each result.</p>
        language: <p>A list of <a href="https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry">BCP 47</a> compliant language codes for the results to be rendered in. If there is no data for the result in the requested language, data will be returned in the default language for the entry.</p>
        political_view: <p>The alpha-2 or alpha-3 character code for the political view of a country. The political view applies to the results of the request to represent unresolved territorial claims through the point of view of the specified country.</p> <p>The following political views are currently supported:</p> <ul> <li> <p> <code>ARG</code>: Argentina's view on the Southern Patagonian Ice Field and Tierra Del Fuego, including the Falkland Islands, South Georgia, and South Sandwich Islands</p> </li> <li> <p> <code>EGY</code>: Egypt's view on Bir Tawil</p> </li> <li> <p> <code>IND</code>: India's view on Gilgit-Baltistan</p> </li> <li> <p> <code>KEN</code>: Kenya's view on the Ilemi Triangle</p> </li> <li> <p> <code>MAR</code>: Morocco's view on Western Sahara</p> </li> <li> <p> <code>RUS</code>: Russia's view on Crimea</p> </li> <li> <p> <code>SDN</code>: Sudan's view on the Halaib Triangle</p> </li> <li> <p> <code>SRB</code>: Serbia's view on Kosovo, Vukovar, and Sarengrad Islands</p> </li> <li> <p> <code>SUR</code>: Suriname's view on the Courantyne Headwaters and Lawa Headwaters</p> </li> <li> <p> <code>SYR</code>: Syria's view on the Golan Heights</p> </li> <li> <p> <code>TUR</code>: Turkey's view on Cyprus and Northern Cyprus</p> </li> <li> <p> <code>TZA</code>: Tanzania's view on Lake Malawi</p> </li> <li> <p> <code>URY</code>: Uruguay's view on Rincon de Artigas</p> </li> <li> <p> <code>VNM</code>: Vietnam's view on the Paracel Islands and Spratly Islands</p> </li> </ul>
        intended_use: <p> Indicates if the query results will be persisted in customer infrastructure. Defaults to <code>SingleUse</code> (not stored). Currently, <code>Autocomplete</code> does not support storage of results. </p>
        key: <p>Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.</p>

    Raises:
        capo_geo_places.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_geo_places.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_geo_places.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_geo_places.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an AWS service.</p>
        capo_geo_places.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_geo_places.types.autocomplete_request.AutocompleteRequest]",
    ) -> AsyncOperationResponse[
        "capo_geo_places.types.autocomplete_response.AutocompleteResponse"
    ]:
        import capo_geo_places._operations.places_service.autocomplete

        (
            output,
            http_response,
        ) = await capo_geo_places._operations.places_service.autocomplete.async_autocomplete(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_geo_places.types.autocomplete_request.AutocompleteRequest",
    ) -> dict[str, Any]:
        import capo_geo_places.types.autocomplete_request

        return capo_geo_places.types.autocomplete_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_geo_places.types.autocomplete_response.AutocompleteResponse",
    ) -> dict[str, Any]:
        import capo_geo_places.types.autocomplete_response

        return capo_geo_places.types.autocomplete_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "Autocomplete", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_geo_places.types.autocomplete_request.AutocompleteRequest = {
        "query_text": query_text
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if bias_position is not None:
        input_["bias_position"] = bias_position
    if filter is not None:
        input_["filter"] = filter
    if postal_code_mode is not None:
        input_["postal_code_mode"] = postal_code_mode
    if additional_features is not None:
        input_["additional_features"] = additional_features
    if language is not None:
        input_["language"] = language
    if political_view is not None:
        input_["political_view"] = political_view
    if intended_use is not None:
        input_["intended_use"] = intended_use
    if key is not None:
        input_["key"] = key

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output