Method: search

Performs a full web search based on the provided request parameters.

HTTP request

GET https://websearchservice.googleapis.com/v1:search

The URL uses gRPC Transcoding syntax.

Query parameters

Parameters
clientContext

object (ClientContext)

Required. Context surrounding the client.

userContext

object (UserContext)

Required. Context provided about the end user.

searchQuery

object (SearchQuery)

Required. Common query parameters for standard search operations.

pageSize

integer

Optional. Number of search results to return (1-20). Default is 10.

pageToken

string

Optional. The next page token from the Web v1.search response.

One search mode must be populated. An empty proto can be a valid selection. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response:
End of mutually exclusive fields.

Request body

The request body must be empty.

Response body

Response to a WSS API search request.

If successful, the response body contains data with the following structure:

JSON representation
{
  "searchResults": [
    {
      object (SearchResult)
    }
  ],
  "searchInfo": {
    object (SearchInfo)
  },
  "nextPageToken": string
}
Fields
searchResults[]

object (SearchResult)

The set of search results.

searchInfo

object (SearchInfo)

Metadata about this search, including timing, total results, and corrections.

nextPageToken

string

Token to retrieve the next page of results. Include this token in the subsequent SearchRequest.page_token field. Will be empty if there are no more results.

ClientContext

Configuration for the v1.search Engine instance.

JSON representation
{
  "clientId": string
}
Fields
clientId

string

Required. Client web property. The standard format is: partner-[name]-[product]-[feature set] Example: partner-example-wss-standard for an example using standard web search.

UserContext

Context provided about the end user.

JSON representation
{
  "ipAddress": string,
  "regionCode": string
}
Fields
ipAddress

string

Required. IP address of the end user.

regionCode

string

Optional. Region code of end user. Only two letter country codes (ISO 3166) are valid.

SearchQuery

Common query parameters for standard search operations.

JSON representation
{
  "query": string,
  "languageCode": string,
  "restrictLanguageCode": string,
  "restrictRegionCode": string,
  "safeSearch": enum (SafeSearchLevel),
  "sortExpression": string,

  // The following is a list of mutually exclusive fields. At most one of the
  // fields will be set in a response:
  "days": integer,
  "weeks": integer,
  "months": integer,
  "years": integer
  // End of mutually exclusive fields.
}
Fields
query

string

Required. The search query string.

Many search features can be represented directly in the query string using Google v1.search operators (see https://support.google.com/websearch/answer/2466433):

languageCode

string

Optional. --- Language & Region --- Sets the user interface language. See https://developers.google.com/web-search-service/xml/web-search/reference/appendixes.html#supported_interface_languages for a list of supported languages.

restrictLanguageCode

string

Optional. Restricts search to documents written in a particular language. See https://developers.google.com/web-search-service/xml/web-search/reference/appendixes.html#language_collection_values for a list of supported languages.

restrictRegionCode

string

Optional. Restricts search results to documents originating in a particular country. Only two letter country codes (ISO 3166) are valid. See https://developers.google.com/web-search-service/xml/web-search/reference/appendixes.html#supported_country_codes for a list of supported countries.

sortExpression

string

Optional. --- Sorting & Range --- The sort expression to apply to the results (e.g., sort=date).

Restricts results to URLs based on date. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response:
days

integer

Optional. Requests results from the specified number of past days.

weeks

integer

Optional. Requests results from the specified number of past weeks.

months

integer

Optional. Requests results from the specified number of past months.

years

integer

Optional. Requests results from the specified number of past years.

End of mutually exclusive fields.

SafeSearchLevel

--- Safety & Filters ---

Enums
SAFE_SEARCH_LEVEL_UNSPECIFIED The safe search level is not specified.
OFF Turns off SafeSearch.
ON Turns on SafeSearch.

WebSearch

This type has no fields.

Parameters specific to web page search.

SearchResult

Represents a single search result item.

JSON representation
{
  "title": string,
  "htmlTitle": string,
  "displayUrl": string,
  "shortenedDisplayUrl": string,
  "snippet": string,
  "htmlSnippet": string,
  "mimeType": string,
  "fileFormat": string
}
Fields
title

string

The title of the search result, in plain text.

htmlTitle

string

The title of the search result, in HTML.

displayUrl

string

The full URL to which the search result is pointing, e.g. http://www.example.com/foo/bar.

shortenedDisplayUrl

string

A shortened version of this search result's URL, e.g. www.example.com.

snippet

string

The snippet of the search result, in plain text.

htmlSnippet

string

The snippet of the search result, in HTML.

mimeType

string

The MIME type of the search result.

fileFormat

string

The file format of the search result.

SearchInfo

Metadata about the search operation.

JSON representation
{
  "searchDuration": string,
  "totalResults": string,
  "formattedTotalResults": string,
  "correctedQuery": string,
  "htmlCorrectedQuery": string
}
Fields
searchDuration

string (Duration format)

The time taken for the server to return search results.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

totalResults

string (int64 format)

The estimated total number of search results available for the query.

formattedTotalResults

string

The estimated total number of search results, formatted according to locale style.

correctedQuery

string

The correctly spelled query.

htmlCorrectedQuery

string

The correctly spelled query, formatted in HTML.