openapi: 3.0.3 info: title: MediaWiki Action articles SPARQL API description: 'The MediaWiki Action API is the original programmatic interface to MediaWiki, exposed under /w/api.php on every MediaWiki installation. All operations dispatch via the ?action= query parameter. The API supports JSON, XML, and PHP serialization; JSON is the recommended format. Wikimedia projects strongly recommend serial (not parallel) calls, the use of maxlag for non-interactive jobs, and a contactable User-Agent header. The Action API remains the primary write interface (edit, upload, login, patrol) even where the Core REST API is also available.' version: '1.45' x-generated-from: documentation x-source-url: https://www.mediawiki.org/wiki/API:Main_page x-last-validated: '2026-05-29' contact: name: Wikimedia Foundation url: https://www.mediawiki.org/wiki/API:Etiquette license: name: CC BY-SA 4.0 url: https://creativecommons.org/licenses/by-sa/4.0/ servers: - url: https://en.wikipedia.org/w description: English Wikipedia - url: https://{lang}.wikipedia.org/w description: Per-language Wikipedia variables: lang: default: en description: Language code - url: https://commons.wikimedia.org/w description: Wikimedia Commons - url: https://www.wikidata.org/w description: Wikidata - url: https://www.mediawiki.org/w description: MediaWiki.org tags: - name: SPARQL description: SPARQL 1.1 query endpoint paths: /sparql: get: operationId: executeSparqlQueryGet summary: Wikidata Query Service SPARQL Execute a SPARQL Query (GET) description: Execute a SPARQL 1.1 SELECT/ASK/CONSTRUCT/DESCRIBE query against the Wikidata graph. Pass the query in the 'query' parameter. Use Accept header to control result format (JSON, XML, CSV, TSV, RDF/XML, Turtle). tags: - SPARQL parameters: - name: query in: query required: true schema: type: string description: SPARQL query text example: SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q146 . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } } LIMIT 10 - name: format in: query schema: type: string enum: - json - xml description: Optional inline format override - name: Accept in: header schema: type: string enum: - application/sparql-results+json - application/sparql-results+xml - text/csv - text/tab-separated-values - application/rdf+xml - text/turtle description: Result format responses: '200': description: Query result content: application/sparql-results+json: schema: $ref: '#/components/schemas/SparqlResults' application/sparql-results+xml: schema: type: string text/csv: schema: type: string text/tab-separated-values: schema: type: string '400': description: Malformed query '500': description: Query execution failed '503': description: Query exceeded the 60s budget x-microcks-operation: delay: 0 dispatcher: FALLBACK post: operationId: executeSparqlQueryPost summary: Wikidata Query Service SPARQL Execute a SPARQL Query (POST) description: Submit a SPARQL query in the request body. Useful when the query is too long for a URL. tags: - SPARQL requestBody: required: true content: application/sparql-query: schema: type: string description: SPARQL query text application/x-www-form-urlencoded: schema: type: object required: - query properties: query: type: string description: SPARQL query text responses: '200': description: Query result content: application/sparql-results+json: schema: $ref: '#/components/schemas/SparqlResults' '400': description: Malformed query '503': description: Query timeout x-microcks-operation: delay: 0 dispatcher: FALLBACK components: schemas: SparqlResults: type: object description: SPARQL 1.1 JSON results format (W3C). properties: head: type: object properties: vars: type: array items: type: string example: - item - itemLabel results: type: object properties: bindings: type: array items: type: object additionalProperties: type: object properties: type: type: string enum: - uri - literal - bnode - typed-literal example: uri value: type: string example: http://www.wikidata.org/entity/Q146 datatype: type: string nullable: true xml:lang: type: string nullable: true boolean: type: boolean description: Result of an ASK query nullable: true securitySchemes: BearerAuth: type: http scheme: bearer description: OAuth 2.0 bearer token from meta.wikimedia.org CookieAuth: type: apiKey in: cookie name: '{wiki}wikiUserID' description: Session cookie obtained via action=login or action=clientlogin