Skip to content

search_place_index_for_position async

search_place_index_for_position(
    index_name: ResourceName,
    position: Position,
    *,
    config_overrides: Optional[AsyncLocationClientConfig] = None,
    max_results: Optional[PlaceIndexSearchResultLimit] = None,
    language: Optional[LanguageTag] = None,
    key: Optional[ApiKey] = None,
) -> SearchPlaceIndexForPositionResponse

This operation is no longer current and may be deprecated in the future. We recommend you upgrade to ReverseGeocode or SearchNearby unless you require Grab data.

  • SearchPlaceIndexForPosition is part of a previous Amazon Location Service Places API (version 1) which has been superseded by a more intuitive, powerful, and complete API (version 2).

  • The version 2 ReverseGeocode operation gives better results in the address reverse-geocoding use case, while the version 2 SearchNearby operation gives better results when searching for businesses and points of interest near a specific location.

  • If you are using an Amazon Web Services SDK or the Amazon Web Services CLI, note that the Places API version 2 is found under geo-places or geo_places, not under location.

  • Since Grab is not yet fully supported in Places API version 2, we recommend you continue using API version 1 when using Grab.

Reverse geocodes a given coordinate and returns a legible address. Allows you to search for Places or points of interest near a given position.

Parameters:

  • index_name (ResourceName) –

    The name of the place index resource you want to use for the search.

  • position (Position) –

    Specifies the longitude and latitude of the position to query.

    This parameter must contain a pair of numbers. The first number represents the X coordinate, or longitude; the second number represents the Y coordinate, or latitude.

    For example, [-123.1174, 49.2847] represents a position with longitude -123.1174 and latitude 49.2847.

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

    An optional parameter. The maximum number of results returned per request.

    Default value: 50

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

    The preferred language used to return results. The value must be a valid BCP 47 language tag, for example, en for English.

    This setting affects the languages used in the results, but not the results themselves. If no language is specified, or not supported for a particular result, the partner automatically chooses a language for the result.

    For an example, we'll use the Greek language. You search for a location around Athens, Greece, with the language parameter set to en. The city in the results will most likely be returned as Athens.

    If you set the language parameter to el, for Greek, then the city in the results will more likely be returned as Αθήνα.

    If the data provider does not have a value for Greek, the result will be in a language that the provider does support.

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

    The optional API key to authorize the request.

Raises:

  • AccessDeniedException –

    The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.

  • InternalServerException –

    The request has failed to process because of an unknown server error, exception, or failure.

  • ResourceNotFoundException –

    The resource that you've entered was not found in your AWS account.

  • ThrottlingException –

    The request was denied because of request throttling.

  • ValidationException –

    The input failed to meet the constraints specified by the AWS service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_location/_services/async_location.py
async def search_place_index_for_position(
    self,
    index_name: "capo_location.types.resource_name.ResourceName",
    position: "capo_location.types.position.Position",
    *,
    config_overrides: Optional[AsyncLocationClientConfig] = None,
    max_results: Optional[
        "capo_location.types.place_index_search_result_limit.PlaceIndexSearchResultLimit"
    ] = None,
    language: Optional["capo_location.types.language_tag.LanguageTag"] = None,
    key: Optional["capo_location.types.api_key.ApiKey"] = None,
) -> "capo_location.types.search_place_index_for_position_response.SearchPlaceIndexForPositionResponse":
    """<important> <p>This operation is no longer current and may be deprecated in the future. We recommend you upgrade to <a href="/location/latest/APIReference/API_geoplaces_ReverseGeocode.html"> <code>ReverseGeocode</code> </a> or <a href="/location/latest/APIReference/API_geoplaces_SearchNearby.html"> <code>SearchNearby</code> </a> unless you require Grab data.</p> <ul> <li> <p> <code>SearchPlaceIndexForPosition</code> is part of a previous Amazon Location Service Places API (version 1) which has been superseded by a more intuitive, powerful, and complete API (version 2).</p> </li> <li> <p>The version 2 <code>ReverseGeocode</code> operation gives better results in the address reverse-geocoding use case, while the version 2 <code>SearchNearby</code> operation gives better results when searching for businesses and points of interest near a specific location.</p> </li> <li> <p>If you are using an Amazon Web Services SDK or the Amazon Web Services CLI, note that the Places API version 2 is found under <code>geo-places</code> or <code>geo_places</code>, not under <code>location</code>.</p> </li> <li> <p>Since Grab is not yet fully supported in Places API version 2, we recommend you continue using API version 1 when using Grab.</p> </li> </ul> </important> <p>Reverse geocodes a given coordinate and returns a legible address. Allows you to search for Places or points of interest near a given position.</p>

    Args:
        index_name: <p>The name of the place index resource you want to use for the search.</p>
        position: <p>Specifies the longitude and latitude of the position to query.</p> <p> This parameter must contain a pair of numbers. The first number represents the X coordinate, or longitude; the second number represents the Y coordinate, or latitude.</p> <p>For example, <code>[-123.1174, 49.2847]</code> represents a position with longitude <code>-123.1174</code> and latitude <code>49.2847</code>.</p>
        max_results: <p>An optional parameter. The maximum number of results returned per request.</p> <p>Default value: <code>50</code> </p>
        language: <p>The preferred language used to return results. The value must be a valid <a href="https://tools.ietf.org/search/bcp47">BCP 47</a> language tag, for example, <code>en</code> for English.</p> <p>This setting affects the languages used in the results, but not the results themselves. If no language is specified, or not supported for a particular result, the partner automatically chooses a language for the result.</p> <p>For an example, we'll use the Greek language. You search for a location around Athens, Greece, with the <code>language</code> parameter set to <code>en</code>. The <code>city</code> in the results will most likely be returned as <code>Athens</code>.</p> <p>If you set the <code>language</code> parameter to <code>el</code>, for Greek, then the <code>city</code> in the results will more likely be returned as <code>Αθήνα</code>.</p> <p>If the data provider does not have a value for Greek, the result will be in a language that the provider does support.</p>
        key: <p>The optional <a href="https://docs.aws.amazon.com/location/previous/developerguide/using-apikeys.html">API key</a> to authorize the request.</p>

    Raises:
        capo_location.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.</p>
        capo_location.errors.internal_server_exception.InternalServerException: <p>The request has failed to process because of an unknown server error, exception, or failure.</p>
        capo_location.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource that you've entered was not found in your AWS account.</p>
        capo_location.errors.throttling_exception.ThrottlingException: <p>The request was denied because of request throttling.</p>
        capo_location.errors.validation_exception.ValidationException: <p>The input failed to meet the constraints specified by the AWS service. </p>
        capo_location.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_location.types.search_place_index_for_position_request.SearchPlaceIndexForPositionRequest]",
    ) -> AsyncOperationResponse[
        "capo_location.types.search_place_index_for_position_response.SearchPlaceIndexForPositionResponse"
    ]:
        import capo_location._operations.location_service.search_place_index_for_position

        (
            output,
            http_response,
        ) = await capo_location._operations.location_service.search_place_index_for_position.async_search_place_index_for_position(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_location.types.search_place_index_for_position_request.SearchPlaceIndexForPositionRequest",
    ) -> dict[str, Any]:
        import capo_location.types.search_place_index_for_position_request

        return capo_location.types.search_place_index_for_position_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_location.types.search_place_index_for_position_response.SearchPlaceIndexForPositionResponse",
    ) -> dict[str, Any]:
        import capo_location.types.search_place_index_for_position_response

        return capo_location.types.search_place_index_for_position_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchPlaceIndexForPosition",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_location.types.search_place_index_for_position_request.SearchPlaceIndexForPositionRequest = {
        "index_name": index_name,
        "position": position,
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if language is not None:
        input_["language"] = language
    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