Skip to main content

search-wikipedia

ai-research-agent / search/search-wikipedia

searchWikipedia()

function searchWikipedia(query, options?): object

Function to query phrase in Wikipedia Search API and return page titles, images and first few sentences of each result. Wikipedia Search API has complex documentation and is dificult to parse and clean up results.

Parameters

ParameterTypeDescription

query

string

search phrase

options?

{ filterDisambiguation: boolean; images: boolean; imageSize: number; limitSearchResults: number; plainText: boolean; searchInTitleOnly: boolean; summarySentenceLimit: number; }

options.filterDisambiguation?

boolean

default=true Filter disambiguation pages

options.images?

boolean

default=true Include image in results

options.imageSize?

number

default=200 Image size in pixels

options.limitSearchResults?

number

default=1 Limit number of search results

options.plainText?

boolean

default=false Return plain text instead of HTML

options.searchInTitleOnly?

boolean

default=false Search in title only

options.summarySentenceLimit?

number

default=3 Limit summary to this many sentences

Returns

object

NameType
resultsobject[]

Example

await searchWikipedia("JavaScript", { plainText: true })

Author

ai-research-agent (2024)