OpenAPI Specification
openapi: 3.1.0
info:
title: Wikidata REST API & MediaWiki Descriptions Items API
description: Wikidata provides multiple APIs for accessing its structured knowledge graph. The Wikibase REST API (OpenAPI-based) provides entity read/write operations. The MediaWiki Action API provides entity retrieval, editing, and search via the wbgetentities, wbsearchentities, and wbeditentity actions. The SPARQL endpoint at query.wikidata.org supports SPARQL 1.1 queries.
version: '1.0'
contact:
name: Wikidata Support
url: https://www.wikidata.org/wiki/Wikidata:Contact_the_development_team
license:
name: CC0 1.0 Universal (Public Domain)
url: https://creativecommons.org/publicdomain/zero/1.0/
servers:
- url: https://www.wikidata.org/w/rest.php/wikibase/v0
description: Wikibase REST API (Beta)
- url: https://www.wikidata.org/w/api.php
description: MediaWiki Action API
tags:
- name: Items
description: Wikidata item (Q-entity) operations
paths:
/entities/items/{item_id}:
get:
operationId: getItem
summary: Wikidata Get a Wikidata Item
description: Returns a Wikidata item (Q-entity) with all its labels, descriptions, aliases, sitelinks, and statements in JSON format.
tags:
- Items
parameters:
- $ref: '#/components/parameters/ItemId'
- $ref: '#/components/parameters/IfNoneMatch'
responses:
'200':
description: Wikidata item
headers:
ETag:
schema:
type: string
description: Item revision ETag
Last-Modified:
schema:
type: string
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
examples:
getItem200Example:
summary: Default getItem 200 response
x-microcks-default: true
value:
id: Q42
type: item
labels:
en: Douglas Adams
fr: Douglas Adams
de: Douglas Adams
descriptions:
en: English author and humorist
fr: auteur et humoriste anglais
aliases:
en:
- DNA
- Douglas Noel Adams
statements:
P31:
- id: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9
rank: normal
property:
id: P31
value:
type: value
content: Q5
sitelinks:
enwiki:
title: Douglas Adams
url: https://en.wikipedia.org/wiki/Douglas_Adams
'304':
description: Not modified (ETag match)
'404':
description: Item not found
x-microcks-operation:
delay: 0
dispatcher: FALLBACK
patch:
operationId: patchItem
summary: Wikidata Update a Wikidata Item
description: Applies a JSON patch to update an item. Requires authentication via OAuth2 or bot password. Includes edit comment and tags.
tags:
- Items
security:
- OAuth2: []
- MediaWikiSession: []
parameters:
- $ref: '#/components/parameters/ItemId'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PatchRequest'
responses:
'200':
description: Item updated
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
examples:
patchItem200Example:
summary: Default patchItem 200 response
x-microcks-default: true
value:
id: Q42
type: item
labels:
en: Douglas Adams
fr: Douglas Adams
de: Douglas Adams
descriptions:
en: English author and humorist
fr: auteur et humoriste anglais
aliases:
en:
- DNA
- Douglas Noel Adams
statements:
P31:
- id: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9
rank: normal
property:
id: P31
value:
type: value
content: Q5
sitelinks:
enwiki:
title: Douglas Adams
url: https://en.wikipedia.org/wiki/Douglas_Adams
'400':
description: Invalid patch
'401':
description: Unauthorized
'403':
description: Forbidden (permissions insufficient)
'409':
description: Edit conflict — base revision mismatch
x-microcks-operation:
delay: 0
dispatcher: FALLBACK
/entities/items:
post:
operationId: createItem
summary: Wikidata Create a New Wikidata Item
description: Creates a new Wikidata item with provided labels, descriptions, aliases, and statements.
tags:
- Items
security:
- OAuth2: []
- MediaWikiSession: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ItemCreate'
responses:
'201':
description: Item created
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
examples:
createItem201Example:
summary: Default createItem 201 response
x-microcks-default: true
value:
id: Q42
type: item
labels:
en: Douglas Adams
fr: Douglas Adams
de: Douglas Adams
descriptions:
en: English author and humorist
fr: auteur et humoriste anglais
aliases:
en:
- DNA
- Douglas Noel Adams
statements:
P31:
- id: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9
rank: normal
property:
id: P31
value:
type: value
content: Q5
sitelinks:
enwiki:
title: Douglas Adams
url: https://en.wikipedia.org/wiki/Douglas_Adams
'400':
description: Invalid item data
'401':
description: Unauthorized
x-microcks-operation:
delay: 0
dispatcher: FALLBACK
components:
schemas:
StatementCreate:
type: object
required:
- property
- value
properties:
property:
type: object
required:
- id
properties:
id:
type: string
pattern: ^P\d+$
value:
$ref: '#/components/schemas/DataValue'
rank:
type: string
enum:
- preferred
- normal
- deprecated
default: normal
qualifiers:
type: array
items:
type: object
references:
type: array
items:
type: object
comment:
type: string
PatchRequest:
type: object
required:
- patch
properties:
patch:
type: array
description: JSON Patch operations (RFC 6902)
items:
type: object
required:
- op
- path
properties:
op:
type: string
enum:
- add
- remove
- replace
- move
- copy
- test
path:
type: string
value:
description: New value for add/replace operations
from:
type: string
description: Source path for move/copy operations
comment:
type: string
description: Edit summary
tags:
type: array
items:
type: string
description: Change tags to apply
bot:
type: boolean
default: false
Sitelink:
type: object
properties:
title:
type: string
description: Wikipedia article title
url:
type: string
format: uri
badges:
type: array
items:
type: string
description: Featured/Good article badges
DataValue:
type: object
properties:
type:
type: string
enum:
- value
- somevalue
- novalue
content:
description: Value content — depends on property datatype
oneOf:
- type: string
- type: number
- type: object
- type: 'null'
Item:
type: object
properties:
id:
type: string
pattern: ^Q\d+$
description: Wikidata item ID
example: Q42
type:
type: string
enum:
- item
labels:
type: object
description: Labels keyed by language code
additionalProperties:
type: string
example:
en: Douglas Adams
fr: Douglas Adams
descriptions:
type: object
description: Descriptions keyed by language code
additionalProperties:
type: string
aliases:
type: object
description: Aliases keyed by language code
additionalProperties:
type: array
items:
type: string
statements:
type: object
description: Statements keyed by property ID
additionalProperties:
type: array
items:
$ref: '#/components/schemas/Statement'
sitelinks:
type: object
description: Sitelinks to Wikipedia and Wikimedia projects
additionalProperties:
$ref: '#/components/schemas/Sitelink'
Statement:
type: object
properties:
id:
type: string
description: Globally unique statement ID
rank:
type: string
enum:
- preferred
- normal
- deprecated
property:
type: object
properties:
id:
type: string
pattern: ^P\d+$
value:
$ref: '#/components/schemas/DataValue'
qualifiers:
type: array
items:
type: object
properties:
property:
type: object
properties:
id:
type: string
value:
$ref: '#/components/schemas/DataValue'
references:
type: array
items:
type: object
properties:
hash:
type: string
parts:
type: array
items:
type: object
ItemCreate:
type: object
properties:
labels:
type: object
additionalProperties:
type: string
descriptions:
type: object
additionalProperties:
type: string
aliases:
type: object
additionalProperties:
type: array
items:
type: string
statements:
type: object
additionalProperties:
type: array
items:
$ref: '#/components/schemas/StatementCreate'
comment:
type: string
description: Edit summary
bot:
type: boolean
default: false
parameters:
IfNoneMatch:
name: If-None-Match
in: header
schema:
type: string
description: ETag for conditional request
ItemId:
name: item_id
in: path
required: true
description: Wikidata item ID
schema:
type: string
pattern: ^Q\d+$
example: Q42
securitySchemes:
OAuth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://www.mediawiki.org/w/index.php?title=Special:OAuth/authorize
tokenUrl: https://www.mediawiki.org/w/index.php?title=Special:OAuth/token
scopes:
editpage: Edit Wikidata items
createeditmovepage: Create new items
MediaWikiSession:
type: apiKey
in: cookie
name: wikidataSession