GET /v1/search
Search Wikipedia content and return matching text chunks. Results are deduplicated by page, with title matches prioritized.
GET https://api.wikirest.com/v1/search
Try it in Playground
Parameters
| Parameter | Type | Required | Description |
q | string | Required | Search query string |
limit | integer | Optional | Results to return (1-50, default: 10) |
offset | integer | Optional | Pagination offset (0-1,000,000, default: 0) |
page_id | integer | Optional | Filter results to a specific Wikipedia page ID |
crop_length | integer | Optional | Text crop length for results (50-2000, default: 400) |
highlight | boolean | Optional | Enable match highlighting (default: true) |
Response
{
"hits": [
{
"id": "12345_1",
"page_id": 12345,
"rev_id": 1234567890,
"title": "Quantum computing",
"section": "Overview",
"text": "Quantum computing is a type of computation...",
"chunk_id": 1,
"url": "https://en.wikipedia.org/wiki/Quantum_computing",
"source": {
"project": "en.wikipedia.org",
"page_id": 12345,
"revision_id": 1234567890,
"source_url": "https://en.wikipedia.org/wiki/Quantum_computing",
"permalink": "https://en.wikipedia.org/w/index.php?curid=12345&oldid=1234567890"
},
"license": {
"name": "CC BY-SA 4.0",
"url": "https://creativecommons.org/licenses/by-sa/4.0/"
},
"_formatted": {
"title": "<em>Quantum</em> <em>computing</em>",
"text": "<em>Quantum</em> <em>computing</em> is a type..."
}
}
],
"query": "quantum computing",
"processingTimeMs": 12,
"limit": 10,
"offset": 0,
"estimatedTotalHits": 1543,
"attribution": {...}
}
Response Fields
| Field | Type | Description |
hits | array | Array of matching chunk objects |
hits[].id | string | Unique chunk ID (format: {page_id}_{chunk_id}) |
hits[].page_id | integer | Wikipedia page ID |
hits[].title | string | Article title |
hits[].section | string | Section heading (empty for intro) |
hits[].text | string | Chunk text content |
hits[]._formatted | object | Fields with <em> highlighting |
query | string | The original search query |
estimatedTotalHits | integer | Approximate total matching results |
Examples
Basic search
curl -H "X-API-Key: YOUR_KEY" \
"https://api.wikirest.com/v1/search?q=quantum+computing"
Search with pagination
curl -H "X-API-Key: YOUR_KEY" \
"https://api.wikirest.com/v1/search?q=machine+learning&limit=20&offset=40"
Search within a specific page
curl -H "X-API-Key: YOUR_KEY" \
"https://api.wikirest.com/v1/search?q=relativity&page_id=736"
Error Responses
| Status | Error | Description |
400 | missing q | Query parameter is required |
401 | unauthorized | API key not provided |
429 | rate_limit_exceeded | Too many requests |