openapi: 3.1.0 info: title: Wikidata REST API & MediaWiki 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: Descriptions description: Description management - name: Items description: Wikidata item (Q-entity) operations - name: Labels description: Label management - name: Properties description: Wikidata property (P-entity) operations - name: Statements description: Statement (claim) 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 /entities/items/{item_id}/labels/{language_code}: get: operationId: getItemLabel summary: Wikidata Get a Label for an Item description: Returns the label for a Wikidata item in a specific language. tags: - Labels parameters: - $ref: '#/components/parameters/ItemId' - $ref: '#/components/parameters/LanguageCode' responses: '200': description: Label value content: application/json: schema: type: string example: "Douglas Adams" examples: getItemLabel200Example: summary: Default getItemLabel 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 '404': description: Label not found for this language x-microcks-operation: delay: 0 dispatcher: FALLBACK put: operationId: setItemLabel summary: Wikidata Set a Label for an Item description: Sets or replaces the label for a Wikidata item in the specified language. tags: - Labels security: - OAuth2: [] - MediaWikiSession: [] parameters: - $ref: '#/components/parameters/ItemId' - $ref: '#/components/parameters/LanguageCode' requestBody: required: true content: application/json: schema: type: object required: - label properties: label: type: string comment: type: string description: Edit summary bot: type: boolean responses: '200': description: Label updated '201': description: Label created x-microcks-operation: delay: 0 dispatcher: FALLBACK /entities/items/{item_id}/descriptions/{language_code}: get: operationId: getItemDescription summary: Wikidata Get a Description for an Item description: Returns the description for a Wikidata item in a specific language. tags: - Descriptions parameters: - $ref: '#/components/parameters/ItemId' - $ref: '#/components/parameters/LanguageCode' responses: '200': description: Description value content: application/json: schema: type: string examples: getItemDescription200Example: summary: Default getItemDescription 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 '404': description: Description not found x-microcks-operation: delay: 0 dispatcher: FALLBACK /entities/items/{item_id}/statements: get: operationId: getItemStatements summary: Wikidata Get Statements for an Item description: >- Returns all statements (claims) for a Wikidata item, optionally filtered by property. Statements include main snak, qualifiers, and references. tags: - Statements parameters: - $ref: '#/components/parameters/ItemId' - name: property in: query schema: type: string pattern: '^P\d+$' description: Filter statements by property ID example: "P31" responses: '200': description: Item statements content: application/json: schema: type: object additionalProperties: type: array items: $ref: '#/components/schemas/Statement' examples: getItemStatements200Example: summary: Default getItemStatements 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 '404': description: Item not found x-microcks-operation: delay: 0 dispatcher: FALLBACK post: operationId: addItemStatement summary: Wikidata Add a Statement to an Item description: Adds a new statement (claim) to a Wikidata item. tags: - Statements security: - OAuth2: [] - MediaWikiSession: [] parameters: - $ref: '#/components/parameters/ItemId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/StatementCreate' responses: '201': description: Statement added content: application/json: schema: $ref: '#/components/schemas/Statement' examples: addItemStatement201Example: summary: Default addItemStatement 201 response x-microcks-default: true value: id: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9 rank: normal property: id: P31 value: type: value content: Q5 qualifiers: [] references: [] x-microcks-operation: delay: 0 dispatcher: FALLBACK /statements/{statement_id}: get: operationId: getStatement summary: Wikidata Get a Single Statement description: Returns a single statement by its globally unique statement ID. tags: - Statements parameters: - name: statement_id in: path required: true schema: type: string description: Statement ID (Q{itemId}${guid}) example: "Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9" responses: '200': description: Statement content: application/json: schema: $ref: '#/components/schemas/Statement' examples: getStatement200Example: summary: Default getStatement 200 response x-microcks-default: true value: id: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9 rank: normal property: id: P31 value: type: value content: Q5 qualifiers: [] references: [] x-microcks-operation: delay: 0 dispatcher: FALLBACK delete: operationId: deleteStatement summary: Wikidata Delete a Statement description: Removes a statement from its parent item. tags: - Statements security: - OAuth2: [] - MediaWikiSession: [] parameters: - name: statement_id in: path required: true schema: type: string example: Q42$F078E5B3-F9A8-480E-B7AC-D97778CBBEF9 requestBody: content: application/json: schema: type: object properties: comment: type: string description: Edit summary responses: '200': description: Statement deleted '404': description: Statement not found x-microcks-operation: delay: 0 dispatcher: FALLBACK /entities/properties/{property_id}: get: operationId: getProperty summary: Wikidata Get a Wikidata Property description: Returns a Wikidata property (P-entity) with labels, descriptions, and statements. tags: - Properties parameters: - name: property_id in: path required: true description: Wikidata property ID schema: type: string pattern: '^P\d+$' example: "P31" responses: '200': description: Property details content: application/json: schema: $ref: '#/components/schemas/Property' examples: getProperty200Example: summary: Default getProperty 200 response x-microcks-default: true value: id: P31 type: property datatype: wikibase-item labels: en: instance of descriptions: en: that class of which this subject is a particular example and member '404': description: Property not found x-microcks-operation: delay: 0 dispatcher: FALLBACK components: 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 parameters: ItemId: name: item_id in: path required: true description: Wikidata item ID schema: type: string pattern: '^Q\d+$' example: "Q42" LanguageCode: name: language_code in: path required: true description: BCP 47 language code schema: type: string example: "en" IfNoneMatch: name: If-None-Match in: header schema: type: string description: ETag for conditional request schemas: 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' 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 Property: type: object properties: id: type: string pattern: '^P\d+$' example: "P31" type: type: string enum: [property] datatype: type: string enum: [wikibase-item, wikibase-property, string, monolingualtext, multilingual-text, quantity, time, globe-coordinate, url, commonsMedia, external-id, math, geo-shape, tabular-data, musical-notation, lexeme, sense, form] labels: type: object additionalProperties: type: string descriptions: type: object additionalProperties: type: string 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 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 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" 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 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