class_docstr: Search engine using SearchApi API. Given a query, it returns a list of URLs that are the most relevant.
  
  See the [SearchApi website](https://www.searchapi.io/) for more details.
docstr: :param api_key: API key for the SearchApi API.  It can be
  explicitly provided or automatically read from the
  environment variable SEARCHAPI_API_KEY (recommended).
  :param top_k: Number of documents to return.
  :param allowed_domains: List of domains to limit the search to.
  :param search_params: Additional parameters passed to the SearchApi API.
  For example, you can set 'num' to 100 to increase the number of search results.
  See the [SearchApi website](https://www.searchapi.io/) for more details.
code: def __init__(
      self,
      api_key: Optional[str] = None,
      top_k: Optional[int] = 10,
      allowed_domains: Optional[List[str]] = None,
      search_params: Optional[Dict[str, Any]] = None,
  ):
      """
      :param api_key: API key for the SearchApi API.  It can be
      explicitly provided or automatically read from the
      environment variable SEARCHAPI_API_KEY (recommended).
      :param top_k: Number of documents to return.
      :param allowed_domains: List of domains to limit the search to.
      :param search_params: Additional parameters passed to the SearchApi API.
      For example, you can set 'num' to 100 to increase the number of search results.
      See the [SearchApi website](https://www.searchapi.io/) for more details.
      """
      api_key = api_key or os.environ.get("SEARCHAPI_API_KEY")
      # we check whether api_key is None or an empty string
      if not api_key:
          msg = (
              "SearchApiWebSearch expects an API key. "
              "Set the SEARCHAPI_API_KEY environment variable (recommended) or pass it explicitly."
          )
          raise ValueError(msg)
  
      self.api_key = api_key
      self.top_k = top_k
      self.allowed_domains = allowed_domains
      self.search_params = search_params or {}
  
file_path: haystack/haystack/components/websearch/searchapi.py
imports: import json
  import logging
  from typing import Dict, List, Optional, Any
  import os
  import requests
  from haystack import Document, component, default_to_dict, ComponentError
label_desc: Use image node_id 1 to create a new SearchApiWebSearch object  with example: obj = SearchApiWebSearch(api_key, top_k, allowed_domains, search_params)