Class: Telnyx::Resources::WebSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/web_search.rb,
lib/telnyx/resources/web_search/research.rb,
sig/telnyx/resources/web_search.rbs,
sig/telnyx/resources/web_search/research.rbs

Defined Under Namespace

Classes: Research

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ WebSearch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of WebSearch.

Parameters:



90
91
92
93
# File 'lib/telnyx/resources/web_search.rb', line 90

def initialize(client:)
  @client = client
  @research = Telnyx::Resources::WebSearch::Research.new(client: client)
end

Instance Attribute Details

#researchTelnyx::Resources::WebSearch::Research (readonly)

Deep research with citations and async task polling.



8
9
10
# File 'lib/telnyx/resources/web_search.rb', line 8

def research
  @research
end

Instance Method Details

#contents(urls:, crawl_timeout: nil, formats: nil, max_age: nil, request_options: {}) ⇒ Telnyx::Models::WebSearchContentsResponse

Some parameter documentations has been truncated, see Models::WebSearchContentsParams for more details.

Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per request (public API limit). Specify which formats to return: html, markdown, metadata.

Parameters:

  • urls (Array<String>)

    List of URLs to retrieve content from (max 20 for public API).

  • crawl_timeout (Integer)

    Timeout for crawling each URL, in seconds (1-60).

  • formats (Array<Symbol, Telnyx::Models::WebSearchContentsParams::Format>)

    Content formats to return. If omitted, html and metadata are returned by def

  • max_age (Integer, nil)

    Maximum age of cached content in seconds. null means no limit.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
# File 'lib/telnyx/resources/web_search.rb', line 76

def contents(params)
  parsed, options = Telnyx::WebSearchContentsParams.dump_request(params)
  @client.request(
    method: :post,
    path: "web_search/contents",
    body: parsed,
    model: Telnyx::Models::WebSearchContentsResponse,
    options: options
  )
end

#create(query:, count: nil, country: nil, exclude_domains: nil, freshness: nil, include_domains: nil, livecrawl: nil, safesearch: nil, request_options: {}) ⇒ Telnyx::Models::WebSearchCreateResponse

Some parameter documentations has been truncated, see Models::WebSearchCreateParams for more details.

Performs a real-time web search and returns structured, LLM-ready JSON results with titles, URLs, descriptions, and snippets. Supports filtering by domain, country, safe search, freshness, and live crawl.

Note: include_domains and exclude_domains cannot be used in the same request. Use one or the other.

Parameters:

  • query (String)

    The search query text.

  • count (Integer)

    Number of results to return (1-100).

  • country (String)

    Two-letter country code (ISO 3166-1 alpha-2) to bias results.

  • exclude_domains (Array<String>)

    Exclude results from these domains (bare hostnames, e.g. pinterest.com).

  • freshness (String)

    Time-based filter for results. Common values: day, week, month, year.

  • include_domains (Array<String>)

    Restrict results to these domains (bare hostnames, e.g. arxiv.org).

  • livecrawl (Boolean)

    When true, the provider crawls pages in real-time for fresh content. The boolean

  • safesearch (Symbol, Telnyx::Models::WebSearchCreateParams::Safesearch)

    Safe search filter level.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



43
44
45
46
47
48
49
50
51
52
# File 'lib/telnyx/resources/web_search.rb', line 43

def create(params)
  parsed, options = Telnyx::WebSearchCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "web_search",
    body: parsed,
    model: Telnyx::Models::WebSearchCreateResponse,
    options: options
  )
end