This is the documentation of version 0.55.1. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias AutocompleteSearchParams

    AutocompleteSearchParams: CommonServiceParams<
        URL,
        AutocompleteSearchResponseAPI,
    > & {
        countries?: string[];
        geoBias?: PointGeoBias;
        limit?: number;
        query: string;
        resultType?: AutocompleteSearchSegmentType[];
    }

    Parameters for autocomplete search suggestions.

    Provides real-time search suggestions as users type, recognizing entities like places, addresses, brands, and categories within partial input.

    Type Declaration

    • Optionalcountries?: string[]

      Restrict results to specific countries.

      List of country codes in ISO 3166-1 alpha-2 or alpha-3 format.

      Only places within these countries will be suggested. Useful for region-specific applications.

      // Alpha-2 codes
      countries: ['US', 'CA', 'MX']

      // Alpha-3 codes
      countries: ['USA', 'CAN', 'MEX']

      // European countries
      countries: ['NL', 'DE', 'FR', 'BE']
    • OptionalgeoBias?: PointGeoBias

      The point to bias suggestions towards, and how far around it to look.

      This endpoint biases by point only — it takes no bounding box. Without radiusMeters the point ranks nearer suggestions higher without restricting them.

      geoBias: { position: [4.9041, 52.3676] }
      geoBias: { position: [4.9041, 52.3676], radiusMeters: 5000 }
    • Optionallimit?: number

      Maximum number of suggestions to return.

      10
      

      1

      100

      limit: 5  // Return up to 5 suggestions
      
    • query: string

      Search query string (partial user input).

      The text to autocomplete. Can be incomplete or partial words.

      Must be properly URL encoded. The service will match this against place names, addresses, brands, and categories.

      query: 'amster'  // Will suggest "Amsterdam"
      query: 'star' // Will suggest "Starbucks" (brand) or "Main Street" (address)
    • OptionalresultType?: AutocompleteSearchSegmentType[]

      Filter results by segment type.

      Restricts suggestions to specific entity types (brands, categories, or plaintext).

      A result is only included if it contains segments of the specified types. Omit this parameter to receive all types.

      // Only brand suggestions (e.g., "Starbucks", "McDonald's")
      resultType: ['brand']

      // Only category suggestions (e.g., "Restaurant", "Hotel")
      resultType: ['category']

      // Brands and categories, exclude addresses
      resultType: ['brand', 'category']

      // All types (default)
      resultType: ['brand', 'category', 'plaintext']

    Key Features:

    • Real-time suggestions as user types
    • Entity recognition (brands, categories, addresses)
    • Position-based relevance ranking
    • Country and area filtering
    • Type-based result filtering

    Use Cases:

    • Search box autocomplete dropdowns
    • Address entry assistance
    • Navigation input fields
    • Location pickers
    // Basic autocomplete
    const params: AutocompleteSearchParams = {
    key: 'your-api-key',
    query: 'pizz',
    limit: 5
    };

    // Autocomplete with position bias
    const biasedParams: AutocompleteSearchParams = {
    key: 'your-api-key',
    query: 'coffee',
    position: [4.9041, 52.3676], // Near Amsterdam
    radiusMeters: 5000,
    limit: 10
    };

    // Filter by result type
    const brandParams: AutocompleteSearchParams = {
    key: 'your-api-key',
    query: 'mcdon',
    resultType: ['brand'], // Only brand suggestions
    countries: ['NL', 'BE'] // Netherlands and Belgium only
    };