Wikipedia

Search Wikipedia

Search a Wikipedia edition, with snippets, match ranges, totals and suggestions.

GET/v1/wikipedia/search
1credit
x-api-keystringheader

API key (`sfk_...`)

Parameters
7
querystringrequiredquery

Search text. Operators such as `insource:`, `incategory:` and `intitle:` work. A plain `insource:/.../` regular expression can be slow; prefer words or `insource:"..."`. At most 300 characters.

min 1 chars · max 300 chars

langstringoptionalquery

Wikimedia edition code, e.g. `en`, `de`, `ja`, `simple` or `zh-min-nan`. Default: `en`.

limitintegeroptionalquery

Results per page, 1 to 500. Default: 50.

≥ 1 · ≤ 500

offsetintegeroptionalquery

First result to return, 0 to 9999. Use `cursor` to continue a walk.

≥ 0 · ≤ 9999

sortstringoptionalquery

Result order: relevance (default), create_timestamp, incoming_links, last_edit, title_natural, just_match, none or random, optionally with `_asc` or `_desc`.

pattern: ^(relevance|create_timestamp|incoming_links|last_edit|title_natural|just_match|none|random)(?:_(asc|desc))?$

namespaceintegeroptionalquery

Namespace id, e.g. `0` for articles or `14` for categories.

≥ -2 · ≤ 999

cursorstringoptionalquery

Cursor from `page.nextCursor` of the previous response. It only works with the same filters. Rankings can shift between pages, so a title can repeat at a page boundary; de-duplicate by `pageId`.

min 1 chars · max 2048 chars

Response fields
33

Endpoint-specific response payload.

datalookupStatus
string

Whether the entity, page or data set exists. A missing entity is `not_found`; an existing entity with no rows is `found` with `empty: true`.

one of: found, not_found

datalang
string

Edition code.

dataquery
string

The search text.

datatotalHits
integernullable

Total matches.

≥ 0

datasuggestion
stringnullable

A suggested spelling, when the search offers one.

datarewrittenQuery
stringnullable

The query as the edition rewrote it, when it did.

dataoffset
integer

First result in this page.

≥ 0

Search hits in this page.

dataresults[]pageId
integernullable

Page id.

dataresults[]ns
integernullable

Namespace id.

dataresults[]title
string

Title.

dataresults[]size
integernullable

Page size in bytes.

dataresults[]wordCount
integernullable

Word count.

dataresults[]timestamp
stringnullable

Last edit, ISO 8601.

dataresults[]snippet
string

Snippet with the search markup removed.

Where the query matched in the snippet.

dataresults[]matches[]start
integer

Start offset in `snippet`.

≥ 0

dataresults[]matches[]end
integer

End offset in `snippet`.

≥ 0

dataresults[]matches[]text
string

Matched text.

dataresults[]titleSnippet
stringnullable

Title snippet, plain.

dataresults[]sectionTitle
stringnullable

Matched section title.

dataresults[]redirectTitle
stringnullable

Matched redirect title.

dataresults[]categorySnippet
stringnullable

Matched category snippet.

Pagination state. `nextCursor` is null on the last page.

datapagehasMore
boolean

Whether another page is available.

datapagenextCursor
stringnullable

Cursor to pass in the next request when more pages exist; null on the last page.

datalimitReached
boolean

True when the walk stopped at the 9999-result ceiling instead of at the last result.

dataempty
boolean

Whether the answer is a valid empty result rather than missing.

Metadata describing the request and billing outcome.

metarequestId
string

Unique request identifier for tracing this API call.

min 1 chars

metacreditsCharged
integer

Credits charged for this request.

≥ 0

metaversion
string

Public API version that served the response.

one of: v1

Code example

curl "https://api.socialfetch.dev/v1/wikipedia/search?query=einstein" \
  -H "x-api-key: YOUR_API_KEY"

Responses

Search Wikipedia