# Wikidata Entity Search - QIDs, Labels and Descriptions (`alaudinburki/wikidata-entity-search`) Actor

Search Wikidata and get flat rows - the QID, label, description and canonical URL for every matching entity. Free public API, no key.

- **URL**: https://apify.com/alaudinburki/wikidata-entity-search.md
- **Developed by:** [alaudin burki](https://apify.com/alaudinburki) (community)
- **Categories:** Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 92.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Wikidata Entity Search — QIDs, Labels and Descriptions

Search Wikidata's public entity search by text and get one flat row per match: the QID, label,
description and canonical entity URL. No key, no account, and no other language requested — the
search runs in English.

### How to use

1. Enter what you are looking for in **Search text** — a person, company, city, chemical or concept.
2. Optionally set **Entity type** to `item`, `property`, `lexeme`, `form` or `sense` to restrict the
   search, and raise **Max rows** / **Max requests** if you expect many matches.
3. Run the Actor. Each match becomes one dataset row, and the `SUMMARY` key-value record shows how
   many rows came back and why the run stopped.

### Inputs

| Input | What it does | Default |
|---|---|---|
| `query` | Text sent to Wikidata's entity search, matched against labels, aliases and descriptions. | none — an empty query returns no matches |
| `type` | Optional entity type: `item`, `property`, `lexeme`, `form` or `sense`. Leave empty for all. | empty |
| `maxItems` | Stop after this many rows. Capped at 20,000. | `500` |
| `maxPages` | Stop after this many requests. Each request asks Wikidata for up to 50 matches. Capped at 200. | `5` |

Example input:

```json
{ "query": "Lahore", "type": "item", "maxItems": 50, "maxPages": 1 }
```

### Output dataset

| Field | Meaning |
|---|---|
| `qid` | The Wikidata identifier, e.g. `Q11739`. Stable and unique across Wikidata; the field to join on. |
| `title` | Page title reported for the match — for items this is the QID itself. |
| `label` | Entity label in English, e.g. `Lahore`. |
| `description` | One-line English description, e.g. `city in Punjab, Pakistan`. |
| `url` | Canonical entity URI, e.g. `http://www.wikidata.org/entity/Q11739`. |
| `pageId` | Numeric page id on wikidata.org. Only meaningful within that wiki, and absent for some matches. |
| `matchType` | Which part of the entity the search matched — typically `label`, `alias` or `description`. |

Each row also carries `id` (`wd:` followed by the QID) and `source`. Rows are de-duplicated by QID and
sorted by QID, so repeated runs produce the same ordering.

### Why this is different

- It returns Wikidata's own identifiers rather than names, so the output joins to other datasets
  instead of needing a second name-matching step.
- The result is already flat. The API nests label, description and match details under differently
  shaped objects; this Actor lifts the useful values into columns you can filter and sort.
- It follows Wikidata's opaque `search-continue` token across pages, so more than the 50 results of a
  single request are reachable.
- Pages are paced 200 ms apart and each request is retried on rate-limit and server errors, so a long
  sweep does not fail on the first throttle.

### Limitations

- **Search hits only, not statements.** There are no claims here — no population, headquarters,
  founding date or sitelinks. Those live in the entity data and would need a separate lookup.
- **English only.** The request fixes `language=en` and `uselang=en`; labels and descriptions in other
  languages are not returned.
- Wikidata is community-edited, so a label or description can change between two runs of the same
  query.
- `pageId` is not present for every match, and it is scoped to wikidata.org alone.
- Results are one page of Wikidata's own relevance ranking at a time, not an exhaustive enumeration of
  a class. A query such as "city in Pakistan" returns text matches, not every city in Pakistan.
- A run stops at `maxItems` or `maxPages`; the `SUMMARY` record says which, via `truncated` and
  `stopReason`.

### FAQ

**What exactly is a QID?**
The `Q` number Wikidata assigns to an item, such as `Q42`. It never changes, so it is safe to store and
use as a key; labels are not.

**Does this return claims like population or coordinates?**
No. It searches entities and returns identity and description. Claims require a second request to the
entity endpoint, which this Actor does not make.

**Why is the label sometimes in a different language than I expected?**
It is always English. Where an English label is missing Wikidata falls back to another language, so
occasional rows carry a non-English label.

**Can I page through every match for a broad term?**
Only up to the caps. Raise `maxItems` and `maxPages`, but note that Wikidata's search is relevance
ranked and is not designed to enumerate a whole class.

**Do I need an account or key?**
No. The search API is public and the Actor sends no credentials.

### Pricing and limits

Pricing is per event: one charge per run, and the current price is on this Actor's Apify pricing panel.
Each run asks for at most 50 matches per request, defaults to 500 rows over 5 requests (raisable to
20,000 rows and 200 requests), paces requests 200 ms apart and retries up to three times on rate-limit
and server errors with a 30-second timeout per request. The source is free to query.

# Actor input Schema

## `query` (type: `string`):

What to search Wikidata for, e.g. a person, company, city or concept.

## `type` (type: `string`):

Optional: item, property, lexeme, form or sense. Leave empty for all.

## `maxItems` (type: `integer`):

Stop after this many rows.

## `maxPages` (type: `integer`):

Stop after this many pages.

## Actor input object example

```json
{
  "query": "Douglas Adams",
  "maxItems": 500,
  "maxPages": 5
}
```

# Actor output Schema

## `results` (type: `string`):

One row per item, with the 7 fields listed under Views.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "Douglas Adams",
    "maxItems": 500,
    "maxPages": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("alaudinburki/wikidata-entity-search").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "query": "Douglas Adams",
    "maxItems": 500,
    "maxPages": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("alaudinburki/wikidata-entity-search").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "Douglas Adams",
  "maxItems": 500,
  "maxPages": 5
}' |
apify call alaudinburki/wikidata-entity-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alaudinburki/wikidata-entity-search"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/XS9eBVulHUPKgtb7r/builds/TbgSfrBVrWdq4unRc/openapi.json
