Wikipedia hub

Wikipedia Search API

Full-text search with snippets, match ranges and totals on any edition.

GET /v1/wikipedia/search

1 credit Failed requests are free

About this endpoint

GET /v1/wikipedia/search?query=einstein&lang=en returns data.results, one row per hit. Each row has pageId, ns, title, size, wordCount, timestamp, snippet, matches, titleSnippet, sectionTitle, redirectTitle and categorySnippet. snippet is plain text, and matches gives the start, end and text of each query match, so you can highlight the hit without parsing markup.

The response also has totalHits, suggestion, rewrittenQuery, offset, limitReached and the page cursor block. The response echoes query, and empty is true when there are no matches.

limit accepts 1 to 500. offset accepts 0 to 9999, and limitReached is true when a walk stopped at that ceiling instead of at the last result. sort accepts relevance (the default), create_timestamp, incoming_links, last_edit, title_natural, just_match, none or random, with an optional _asc or _desc suffix. namespace limits the search to one namespace. Rankings can shift between pages, so a title can repeat at a page boundary; de-duplicate by pageId.

Wikipedia Search API FAQ

How do I highlight the matched words?

Use data.results[].matches. Each match gives start and end offsets into snippet and the matched text. The snippet is already plain text, so offsets are safe to slice.

How do I page through results?

Use the cursor from data.page.nextCursor while data.page.hasMore is true. offset is also available for a direct jump, up to 9999. limitReached is true when a walk hit that ceiling.

Does the query support search operators?

Yes. Operators such as insource:, incategory: and intitle: work. A regular-expression insource:/.../ query can be slow and may time out, so prefer words or insource:"...". query is limited to 300 characters and is required.

How is search paging billed?

Pricing is documented on the operation in the API registry (shown on this page). Confirm on every response with meta.creditsCharged: that field is the billing source of truth. Each paginated page is a separate billed request.