sources picks the kinds of results a search returns, and categories adds PDFs, papers and videos. Each one comes back in its own list under data.
Search several sources
Get an API key in the Quickstart. This request asks for news, images, research papers and YouTube videos, two of each.Read the response
data has a news, an images, a research and a videos list. This real response is cut to one row of each, and the snippets are shortened.
costUsd is $0.004: $0.001 for each of the four lists.
Sources and categories
Each entry is a string or an object with a
type, such as "web" or { "type": "web" }. Send up to 5 sources. The web source is the only one that takes its own tbs, location, country and lang: { "type": "web", "tbs": "qdr:w", "country": "de" }. See Filters.
With no sources you get web results. With only research or videos in categories, no web search runs. With research and web, the web results are limited to academic sites.
Search PDFs
categories: ["pdf"] searches for PDF files. Any web result whose address ends in .pdf also gets category: "pdf".
Limits and errors
- A source that fails while others answer is left out, and
warningnames it, such asnews: …. When every source fails, the call fails and costs nothing. - An empty list costs nothing.
warningsays when a list came back empty, for exampleresearch: no papers match these words. Try fewer or more general words. - With only
researchorvideosand nosources, the fields that narrow web, news and image results return400 invalidRequest:tbs,location,lang,includeDomains,excludeDomains,countryandscrapeOptions. The error names the field, such astbs narrows web, news and image results. Add them to sources or leave tbs out.Add a source or leave the field out. - An entry that is not
web,newsorimagesinsourcesreturns400 invalidRequest. The error saysSend web, news or images, as a string or {"type":"web"}. - An entry that is not
pdf,researchorvideosincategoriesreturns400 invalidRequest. The error saysSend pdf, research or videos, as a string or {type}. - An
imagessearch needs words next toimagesize:orlarger:, or it returns400 invalidRequest.
Related
- Filters narrows each source by site, time, place and language.
- Page content reads each web and news result.
- Papers searches papers on their own and reads one by id.
- Search overview lists every search field.