> ## Documentation Index
> Fetch the complete documentation index at: https://jigsaw-13.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Suggestion

> Get suggestions for a given query in real time.

### Query

<ParamField query="query" type="string" required>
  The search value. The maximum query character length is 200.
</ParamField>

<Snippet file="header.mdx" />

### Response

<ResponseField name="success" type="boolean">
  Indicates whether the call was successful.
</ResponseField>

<ResponseField name="_usage" type="object" optional>
  Usage information for the API call.

  <Expandable title="_usage">
    <ResponseField name="input_tokens" type="number">
      Number of input tokens processed.
    </ResponseField>

    <ResponseField name="output_tokens" type="number">
      Number of output tokens generated.
    </ResponseField>

    <ResponseField name="inference_time_tokens" type="number">
      Number of tokens processed during inference time.
    </ResponseField>

    <ResponseField name="total_tokens" type="number">
      Total number of tokens used (input + output).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="log_id" type="string" optional>
  A unique identifier for the request
</ResponseField>

<ResponseField name="suggestions" type="array<string>">
  Array of search suggestions.
</ResponseField>

<RequestExample>
  ```javascript Javascript theme={null}
  import { JigsawStack } from "jigsawstack";

  const jigsaw = JigsawStack({ apiKey: "your-api-key" });

  const response = await jigsaw.web.search_suggestions({
    "query": "What is the capital"
  })
  ```

  ```python Python theme={null}
  from jigsawstack import JigsawStack

  jigsaw = JigsawStack(api_key="your-api-key")

  response = jigsaw.web.search_suggestions({
    "query": "What is the capital"
  })
  ```

  ```bash Curl theme={null}
  curl https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital \
  -X GET \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: your-api-key'
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Content-Type: application/json',
  'x-api-key: your-api-key',
  ]);

  $response = curl_exec($ch);

  curl_close($ch);

  ```

  ```ruby Ruby theme={null}
  require 'net/http'

  uri = URI('https://api.jigsawstack.com/v1/web/search/suggest')
  params = {
  :query => 'What is the capital',
  }
  uri.query = URI.encode_www_form(params)

  req = Net::HTTP::Get.new(uri)
  req.content_type = 'application/json'
  req['x-api-key'] = 'your-api-key'

  req_options = {
  use_ssl: uri.scheme == 'https'
  }
  res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(req)
  end

  ```

  ```go Go theme={null}
  package main

  import (
  "fmt"
  "io"
  "log"
  "net/http"
  )

  func main() {
  client := &http.Client{}
  req, err := http.NewRequest("GET", "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital", nil)
  if err != nil {
  	log.Fatal(err)
  }
  req.Header.Set("Content-Type", "application/json")
  req.Header.Set("x-api-key", "your-api-key")
  resp, err := client.Do(req)
  if err != nil {
  	log.Fatal(err)
  }
  defer resp.Body.Close()
  bodyText, err := io.ReadAll(resp.Body)
  if err != nil {
  	log.Fatal(err)
  }
  fmt.Printf("%s\n", bodyText)
  }

  ```

  ```java Java theme={null}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  HttpClient client = HttpClient.newHttpClient();

  HttpRequest request = HttpRequest.newBuilder()
  .uri(URI.create("https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital"))
  .GET()
  .setHeader("Content-Type", "application/json")
  .setHeader("x-api-key", "your-api-key")
  .build();

  HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital")!
  let headers = [
  "Content-Type": "application/json",
  "x-api-key": "your-api-key"
  ]

  var request = URLRequest(url: url)
  request.allHTTPHeaderFields = headers

  let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
  if let error = error {
      print(error)
  } else if let data = data {
      let str = String(data: data, encoding: .utf8)
      print(str ?? "")
  }
  }

  task.resume()

  ```

  ```dart Dart theme={null}
  import 'package:http/http.dart' as http;

  void main() async {
  final headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'your-api-key',
  };

  final params = {
  'query': 'What is the capital',
  };

  final url = Uri.parse('https://api.jigsawstack.com/v1/web/search/suggest')
    .replace(queryParameters: params);

  final res = await http.get(url, headers: headers);
  final status = res.statusCode;
  if (status != 200) throw Exception('http.get error: statusCode= $status');

  print(res.body);
  }

  ```

  ```kotlin Kotlin theme={null}
  import java.io.IOException
  import okhttp3.OkHttpClient
  import okhttp3.Request

  val client = OkHttpClient()

  val request = Request.Builder()
  .url("https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital")
  .header("Content-Type", "application/json")
  .header("x-api-key", "your-api-key")
  .build()

  client.newCall(request).execute().use { response ->
  if (!response.isSuccessful) throw IOException("Unexpected code $response")
  response.body!!.string()
  }

  ```

  ```csharp C# theme={null}
  using System.Net.Http.Headers;
  using System.Net.Http.Json;

  HttpClient client = new HttpClient();

  HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://api.jigsawstack.com/v1/web/search/suggest?query=What+is+the+capital");
  request.Headers.Add("x-api-key", "your-api-key");

  HttpResponseMessage response = await client.SendAsync(request);
  response.EnsureSuccessStatusCode();
  string responseBody = await response.Content.ReadAsStringAsync();

  Console.WriteLine(responseBody);
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "suggestions": [
          "what is the capital of california",
          "what is the capital of canada",
          "what is the capital of australia",
          "what is the capital of texas",
          "what is the capital of the united states",
          "what is the capital of florida",
          "what is the capital of brazil",
          "what is the capital of new york",
          "what is the capital of alaska",
          "what is the capital of italy",
          "what is the capital of japan",
          "what is the capital gains tax rate",
          "what is the capital of maine",
          "what is the capital of illinois",
          "what is the capital of turkey"
    ],
    "_usage": {
          "input_tokens": 8,
          "output_tokens": 134,
          "inference_time_tokens": 250,
          "total_tokens": 392
    }
  }
  ```
</ResponseExample>
