Skip to content

search_nearby

search_nearby(
    query_position: Position,
    *,
    config_overrides: Optional[GeoPlacesClientConfig] = None,
    query_radius: Optional[DistanceMeters] = None,
    max_results: Optional[int] = None,
    filter: Optional[SearchNearbyFilter] = None,
    additional_features: Optional[SearchNearbyAdditionalFeatureList] = None,
    language: Optional[LanguageTag] = None,
    political_view: Optional[CountryCode] = None,
    intended_use: Optional[SearchNearbyIntendedUse] = None,
    next_token: Optional[Token] = None,
    key: Optional[ApiKey] = None,
) -> SearchNearbyResponse

SearchNearby queries for points of interest within a radius from a central coordinates, returning place results with optional filters such as categories, business chains, food types and more. The API returns details such as a place name, address, phone, category, food type, contact, opening hours. Also, the API can return phonemes, time zones and more based on requested parameters. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

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

Parameters:

  • query_position (Position) –

    The position in World Geodetic System (WGS 84) format: [longitude, latitude] for which you are querying nearby results for. Results closer to the position will be ranked higher then results further away from the position

  • query_radius (Optional[DistanceMeters], default: None ) –

    The maximum distance in meters from the QueryPosition from which a result will be returned.

    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: 20

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

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

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

    A list of optional additional parameters, such as time zone, 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.

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

    Indicates if the query results will be persisted in customer infrastructure. Defaults to SingleUse (not stored). Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

    When storing SearchNearby responses, you must set this field to Storage to comply with the terms of service. These requests will be charged at a higher rate. Please review the user agreement and service pricing structure to determine the correct setting for your use case.

  • next_token (Optional[Token], default: None ) –

    If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page.

  • 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/geo_places.py
def search_nearby(
    self,
    query_position: "capo_geo_places.types.position.Position",
    *,
    config_overrides: Optional[GeoPlacesClientConfig] = None,
    query_radius: Optional[
        "capo_geo_places.types.distance_meters.DistanceMeters"
    ] = None,
    max_results: Optional[int] = None,
    filter: Optional[
        "capo_geo_places.types.search_nearby_filter.SearchNearbyFilter"
    ] = None,
    additional_features: Optional[
        "capo_geo_places.types.search_nearby_additional_feature_list.SearchNearbyAdditionalFeatureList"
    ] = 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.search_nearby_intended_use.SearchNearbyIntendedUse"
    ] = None,
    next_token: Optional["capo_geo_places.types.token.Token"] = None,
    key: Optional["capo_geo_places.types.api_key.ApiKey"] = None,
) -> "capo_geo_places.types.search_nearby_response.SearchNearbyResponse":
    """<p> <code>SearchNearby</code> queries for points of interest within a radius from a central coordinates, returning place results with optional filters such as categories, business chains, food types and more. The API returns details such as a place name, address, phone, category, food type, contact, opening hours. Also, the API can return phonemes, time zones and more based on requested parameters. 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/search-nearby.html">Search Nearby</a> in the <i>Amazon Location Service Developer Guide</i>.</p>

    Args:
        query_position: <p>The position in World Geodetic System (WGS 84) format: [longitude, latitude] for which you are querying nearby results for. Results closer to the position will be ranked higher then results further away from the position</p>
        query_radius: <p>The maximum distance in meters from the QueryPosition from which a result will be returned.</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: 20</p>
        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>
        additional_features: <p>A list of optional additional parameters, such as time zone, 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>
        intended_use: <p> Indicates if the query results will be persisted in customer infrastructure. Defaults to <code>SingleUse</code> (not stored). 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> <note> <p>When storing <code>SearchNearby</code> responses, you <i>must</i> set this field to <code>Storage</code> to comply with the terms of service. These requests will be charged at a higher rate. Please review the <a href="https://aws.amazon.com/location/sla/">user agreement</a> and <a href="https://aws.amazon.com/location/pricing/">service pricing structure</a> to determine the correct setting for your use case.</p> </note>
        next_token: <p>If <code>nextToken</code> is returned, there are more results available. The value of <code>nextToken</code> is a unique pagination token for each page. </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.
    """

    def _handler(
        req: "OperationRequest[capo_geo_places.types.search_nearby_request.SearchNearbyRequest]",
    ) -> OperationResponse[
        "capo_geo_places.types.search_nearby_response.SearchNearbyResponse"
    ]:
        import capo_geo_places._operations.places_service.search_nearby

        output, http_response = (
            capo_geo_places._operations.places_service.search_nearby.search_nearby(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

        return capo_geo_places.types.search_nearby_request.redact_sensitive(input_)

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

        return capo_geo_places.types.search_nearby_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "SearchNearby", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_geo_places.types.search_nearby_request.SearchNearbyRequest = {
        "query_position": query_position
    }
    if query_radius is not None:
        input_["query_radius"] = query_radius
    if max_results is not None:
        input_["max_results"] = max_results
    if filter is not None:
        input_["filter"] = filter
    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 next_token is not None:
        input_["next_token"] = next_token
    if key is not None:
        input_["key"] = key

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output