LocationServicePlacesV2 / Client / autocomplete

autocomplete

LocationServicePlacesV2.Client.autocomplete(**kwargs)

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.

See also: AWS API Documentation

Request Syntax

response = client.autocomplete(
    QueryText='string',
    MaxResults=123,
    BiasPosition=[
        123.0,
    ],
    Filter={
        'BoundingBox': [
            123.0,
        ],
        'Circle': {
            'Center': [
                123.0,
            ],
            'Radius': 123
        },
        'IncludeCountries': [
            'string',
        ],
        'IncludePlaceTypes': [
            'Locality'|'PostalCode',
        ]
    },
    PostalCodeMode='MergeAllSpannedLocalities'|'EnumerateSpannedLocalities',
    AdditionalFeatures=[
        'Core',
    ],
    Language='string',
    PoliticalView='string',
    IntendedUse='SingleUse',
    Key='string'
)
Parameters:
  • QueryText (string) –

    [REQUIRED]

    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.

    Note

    The fields QueryText, and QueryID are mutually exclusive.

  • MaxResults (integer) – An optional limit for the number of results returned in a single call.

  • BiasPosition (list) –

    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 WSG84 format.

    Note

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

    • (float) –

  • Filter (dict) –

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

    • BoundingBox (list) –

      The bounding box enclosing the geometric shape (area or line) that an individual result covers.

      The bounding box formed is defined as a set 4 coordinates: [{westward lng}, {southern lat}, {eastward lng}, {northern lat}]

      • (float) –

    • Circle (dict) –

      The Circle that all results must be in.

      • Center (list) – [REQUIRED]

        The center position, in longitude and latitude, of the FilterCircle.

        • (float) –

      • Radius (integer) – [REQUIRED]

        The radius, in meters, of the FilterCircle.

    • IncludeCountries (list) –

      A list of countries that all results must be in. Countries are represented by either their alpha-2 or alpha-3 character codes.

      • (string) –

    • IncludePlaceTypes (list) –

      The included place types.

      • (string) –

  • PostalCodeMode (string) – 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.

  • AdditionalFeatures (list) –

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

    • (string) –

  • Language (string) – 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.

  • PoliticalView (string) –

    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

  • IntendedUse (string) – Indicates if the results will be stored. Defaults to SingleUse, if left empty.

  • Key (string) – Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

Return type:

dict

Returns:

Response Syntax

{
    'PricingBucket': 'string',
    'ResultItems': [
        {
            'PlaceId': 'string',
            'PlaceType': 'Country'|'Region'|'SubRegion'|'Locality'|'District'|'SubDistrict'|'PostalCode'|'Block'|'SubBlock'|'Intersection'|'Street'|'PointOfInterest'|'PointAddress'|'InterpolatedAddress'|'SecondaryAddress',
            'Title': 'string',
            'Address': {
                'Label': 'string',
                'Country': {
                    'Code2': 'string',
                    'Code3': 'string',
                    'Name': 'string'
                },
                'Region': {
                    'Code': 'string',
                    'Name': 'string'
                },
                'SubRegion': {
                    'Code': 'string',
                    'Name': 'string'
                },
                'Locality': 'string',
                'District': 'string',
                'SubDistrict': 'string',
                'PostalCode': 'string',
                'Block': 'string',
                'SubBlock': 'string',
                'Intersection': [
                    'string',
                ],
                'Street': 'string',
                'StreetComponents': [
                    {
                        'BaseName': 'string',
                        'Type': 'string',
                        'TypePlacement': 'BeforeBaseName'|'AfterBaseName',
                        'TypeSeparator': 'string',
                        'Prefix': 'string',
                        'Suffix': 'string',
                        'Direction': 'string',
                        'Language': 'string'
                    },
                ],
                'AddressNumber': 'string',
                'Building': 'string',
                'SecondaryAddressComponents': [
                    {
                        'Number': 'string'
                    },
                ]
            },
            'Distance': 123,
            'Language': 'string',
            'PoliticalView': 'string',
            'Highlights': {
                'Title': [
                    {
                        'StartIndex': 123,
                        'EndIndex': 123,
                        'Value': 'string'
                    },
                ],
                'Address': {
                    'Label': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'Country': {
                        'Code': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ],
                        'Name': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ]
                    },
                    'Region': {
                        'Code': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ],
                        'Name': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ]
                    },
                    'SubRegion': {
                        'Code': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ],
                        'Name': [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ]
                    },
                    'Locality': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'District': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'SubDistrict': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'Street': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'Block': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'SubBlock': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'Intersection': [
                        [
                            {
                                'StartIndex': 123,
                                'EndIndex': 123,
                                'Value': 'string'
                            },
                        ],
                    ],
                    'PostalCode': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'AddressNumber': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ],
                    'Building': [
                        {
                            'StartIndex': 123,
                            'EndIndex': 123,
                            'Value': 'string'
                        },
                    ]
                }
            }
        },
    ]
}

Response Structure

  • (dict) –

    • PricingBucket (string) –

      The pricing bucket for which the query is charged at.

      For more information on pricing, please visit Amazon Location Service Pricing.

    • ResultItems (list) –

      List of places or results returned for a query.

      • (dict) –

        A result matching the input query text.

        • PlaceId (string) –

          The PlaceId of the place associated with this result. This can be used to look up additional details about the result via GetPlace.

        • PlaceType (string) –

          PlaceType describes the type of result entry returned.

        • Title (string) –

          A formatted string for display when presenting this result to an end user.

        • Address (dict) –

          The address associated with this result.

          • Label (string) –

            Assembled address value built out of the address components, according to the regional postal rules. This is the correctly formatted address.

          • Country (dict) –

            The country component of the address.

            • Code2 (string) –

              Country, represented by its alpha 2-character code.

            • Code3 (string) –

              Country, represented by its alpha t-character code.

            • Name (string) –

              Name of the country.

          • Region (dict) –

            The region or state results should be present in.

            Example: North Rhine-Westphalia.

            • Code (string) –

              Abbreviated code for a the state, province or region of the country.

              Example: BC.

            • Name (string) –

              Name for a the state, province, or region of the country.

              Example: British Columbia.

          • SubRegion (dict) –

            The sub-region or county for which results should be present in.

            • Code (string) –

              Abbreviated code for the county or sub-region.

            • Name (string) –

              Name for the county or sub-region.

          • Locality (string) –

            The city or locality of the address.

            Example: Vancouver.

          • District (string) –

            The district or division of a locality associated with this address.

          • SubDistrict (string) –

            A subdivision of a district.

            Example: Minden-Lübbecke.

          • PostalCode (string) –

            An alphanumeric string included in a postal address to facilitate mail sorting, such as post code, postcode, or ZIP code, for which the result should possess.

          • Block (string) –

            Name of the block.

            Example: Sunny Mansion 203 block: 2 Chome

          • SubBlock (string) –

            Name of sub-block.

            Example: Sunny Mansion 203 sub-block: 4

          • Intersection (list) –

            Name of the streets in the intersection.

            Example: ["Friedrichstraße","Unter den Linden"]

            • (string) –

          • Street (string) –

            The name of the street results should be present in.

          • StreetComponents (list) –

            Components of the street.

            Example: Younge from the “Younge street”.

            • (dict) –

              Components of a street.

              • BaseName (string) –

                Base name part of the street name.

                Example: Younge from the “Younge street”.

              • Type (string) –

                Street type part of the street name.

                Example: "avenue".

              • TypePlacement (string) –

                Defines if the street type is before or after the base name.

              • TypeSeparator (string) –

                Defines a separator character such as "" or " " between the base name and type.

              • Prefix (string) –

                A prefix is a directional identifier that precedes, but is not included in, the base name of a road.

                Example: E for East.

              • Suffix (string) –

                A suffix is a directional identifier that follows, but is not included in, the base name of a road.

                Example W for West.

              • Direction (string) –

                Indicates the official directional identifiers assigned to highways.

              • Language (string) –

                A 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.

          • AddressNumber (string) –

            The number that identifies an address within a street.

          • Building (string) –

            The name of the building at the address.

          • SecondaryAddressComponents (list) –

            Components that correspond to secondary identifiers on an Address. Secondary address components include information such as Suite or Unit Number, Building, or Floor.

            • (dict) –

              Components that correspond to secondary identifiers on an address. The only component type supported currently is Unit.

              • Number (string) –

                Number that uniquely identifies a secondary address.

        • Distance (integer) –

          The distance in meters between the center of the search area and this result. Useful to evaluate how far away from the original bias position the result is.

        • Language (string) –

          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.

        • PoliticalView (string) –

          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.

        • Highlights (dict) –

          Indicates the starting and ending index of the place in the text query that match the found title.

          • Title (list) –

            Indicates where the title field in the result matches the input query.

            • (dict) –

              Indicates the starting and ending index of the text query that match the found title.

              • StartIndex (integer) –

                Start index of the highlight.

              • EndIndex (integer) –

                End index of the highlight.

              • Value (string) –

                The highlight’s value.

          • Address (dict) –

            Describes how part of the result address match the input query.

            • Label (list) –

              Indicates the starting and ending indexes for result items where they are identified to match the input query. This should be used to provide emphasis to output display to make selecting the correct result from a list easier for end users.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • Country (dict) –

              The alpha-2 or alpha-3 character code for the country that the results will be present in.

              • Code (list) –

                Indicates the starting and ending index of the country code in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

              • Name (list) –

                Indicates the starting and ending index of the country code in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

            • Region (dict) –

              The region or state results should be to be present in.

              Example: North Rhine-Westphalia.

              • Code (list) –

                Indicates the starting and ending index of the region in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

              • Name (list) –

                Indicates the starting and ending index of the region name in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

            • SubRegion (dict) –

              The sub-region or county for which results should be present in.

              • Code (list) –

                Indicates the starting and ending index of the sub-region in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

              • Name (list) –

                Indicates the starting and ending index of the name in the text query that match the found title.

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

            • Locality (list) –

              The city or locality results should be present in.

              Example: Vancouver.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • District (list) –

              The district or division of a city the results should be present in.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • SubDistrict (list) –

              Indicates the starting and ending index of the title in the text query that match the found title.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • Street (list) –

              The name of the street results should be present in.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • Block (list) –

              Name of the block.

              Example: Sunny Mansion 203 block: 2 Chome

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • SubBlock (list) –

              Name of sub-block.

              Example: Sunny Mansion 203 sub-block: 4

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • Intersection (list) –

              Name of the streets in the intersection. For example: e.g. [“Friedrichstraße”,”Unter den Linden”]

              • (list) –

                • (dict) –

                  Indicates the starting and ending index of the text query that match the found title.

                  • StartIndex (integer) –

                    Start index of the highlight.

                  • EndIndex (integer) –

                    End index of the highlight.

                  • Value (string) –

                    The highlight’s value.

            • PostalCode (list) –

              An alphanumeric string included in a postal address to facilitate mail sorting, such as post code, postcode, or ZIP code for which the result should possess.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • AddressNumber (list) –

              The house number or address results should have.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

            • Building (list) –

              The name of the building at the address.

              • (dict) –

                Indicates the starting and ending index of the text query that match the found title.

                • StartIndex (integer) –

                  Start index of the highlight.

                • EndIndex (integer) –

                  End index of the highlight.

                • Value (string) –

                  The highlight’s value.

Exceptions