openapi: 3.0.1 info: version: 0.2.1 title: Content translation service description: Content translation service for translating mediawiki pages between languages. termsOfService: https://wikimediafoundation.org/wiki/Terms_of_Use contact: name: the Wikimedia Language team url: https://www.mediawiki.org/wiki/Wikimedia_Language_engineering license: name: GPL-2.0-or-later url: http://opensource.org/licenses/GPL-2.0 x-default-params: domain: en.wikipedia.org paths: # from routes/root.js /robots.txt: get: tags: - Root - Robots summary: Gets robots.txt responses: 200: description: Success content: text/plain: example: "User-agent: * \nDisallow: /" x-amples: - title: robots.txt check request: {} response: status: 200 /: get: tags: - Root summary: The root service end-point responses: 200: description: Success x-amples: - title: root with no query params request: {} response: status: 302 - title: spec from root request: query: spec: true response: status: 200 - title: doc from root request: query: doc: true response: status: 302 - title: root with wrong query param request: query: fooo: true response: status: 302 # from routes/v1.js /v1/page/{language}/{title}: get: tags: - Page content summary: Fetches segmented mediawiki page parameters: - $ref: "#/components/parameters/language" - $ref: "#/components/parameters/title" responses: 200: description: Page fetched successfully content: application/json: schema: type: object properties: sourceLanguage: type: string example: es title: type: string example: Albert Einstein revision: type: string example: 165157183 segmentedContent: type: string example: lorem ipsum 404: description: Page not found x-amples: - title: Fetch enwiki protected page request: params: language: en title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein response: status: 200 headers: content-type: application/json - title: Fetch protected page with multi-word title request: params: language: en title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein response: status: 200 headers: content-type: application/json /v1/page/{language}/{title}/{revision}: get: tags: - Page content summary: Fetches segmented mediawiki page with revision parameters: - $ref: "#/components/parameters/language" - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/revision" responses: 200: description: Success content: application/json: schema: type: object properties: sourceLanguage: type: string example: en title: type: string example: Albert Einstein revision: type: string example: 1234565 segmentedContent: type: string example: lorem ipsum 404: description: Page not found x-amples: - title: Fetch enwiki protected page with revision request: params: language: en title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein revision: 1086816359 response: status: 200 headers: content-type: application/json /v1/mt/{from}/{to}: post: tags: - Machine translation summary: Fetches the machine translation. Some providers require an authorization header and it is forbidden to use them outside the Content Translation tool. parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" requestBody: content: application/json: schema: required: - html example: hello world: value: { html:

hello world

} responses: 200: description: Machine translation fetched successfully content: application/json: examples: hello world: value: { html:

Bonjour le monde

} 400: description: Invalid language code specified 500: description: Internal error x-amples: - title: Machine translate an HTML fragment using TestClient. request: params: from: en to: qqq body: html:

Oxygen is a chemical element with symbol O and atomic number 8.

response: status: 200 body: contents: /.+/ headers: content-type: application/json /v1/mt/{from}/{to}/{mtprovider}: post: tags: - Machine translation summary: Fetches the machine translation. Some providers require an authorization header and it is forbidden to use them outside the Content Translation tool. parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/mtprovider" requestBody: content: application/json: schema: required: - html properties: html: type: string description: The HTML content to translate x-textarea: true examples: hello world: value: { html:

hello world

} Let's translate: value: { html:

Let's translate this paragraph.

} responses: 200: description: Machine translation fetched successfully content: application/json: examples: hello world: value: { html:

Bonjour le monde

} 400: description: Not found x-amples: - title: Machine translate an HTML fragment using TestClient. request: params: from: en to: qqq provider: TestClient body: html:

Oxygen is a chemical element with symbol O and atomic number 8.

response: status: 200 body: contents: /.+/ headers: content-type: application/json /v1/list/pair/{from}/{to}: get: tags: - Tools summary: Lists the tools for a given language pair parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" responses: 200: description: Lists the tools for a given language pair fetched successfully content: application/json: schema: type: object properties: mt: type: array items: type: string example: { mt: [ Google, Elia, MinT ] } 500: description: Internal error x-amples: - title: Get the tools between two language pairs request: params: from: en to: es response: status: 200 headers: content-type: application/json /v1/list/languagepairs: get: tags: - Languages - Service information summary: Lists the language pairs supported by the server responses: 200: description: Success content: application/json: schema: type: object properties: sources: type: array items: type: string description: Source language code x-amples: - title: Get all the language pairs response: status: 200 headers: content-type: application/json /v1/list/{tool}: get: tags: - Tools - Service information summary: Lists all language pairs that tool supports. parameters: - $ref: "#/components/parameters/tool" responses: 200: description: List of all language pairs content: application/json: schema: type: object properties: sources: type: object 404: description: Not Found 500: description: Server Error x-amples: - title: Get the MT tool between two language pairs request: params: tool: mt response: status: 200 headers: content-type: application/json /v1/list/{tool}/{from}/{to}: get: tags: - Tools - Service information summary: Lists the providers for the tool in that language pair. parameters: - $ref: "#/components/parameters/tool" - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" responses: 200: description: List mt tools available for the language pairs content: application/json: schema: type: object properties: mt: type: array items: type: string example: { mt: [ Google, Elia, MinT ] } 404: description: Not Found 500: description: Server Error x-amples: - title: Get the MT tool between two language pairs request: params: from: en to: es tool: mt response: status: 200 headers: content-type: application/json # from routes/v2.js /v2/page/{sourcelanguage}/{targetlanguage}/{title}: get: tags: - Page content summary: Fetches segmented mediawiki page parameters: - $ref: "#/components/parameters/sourcelanguage" - $ref: "#/components/parameters/targetlanguage" - $ref: "#/components/parameters/title" responses: 200: description: Success 404: description: Not Found 500: description: Server Error x-amples: - title: Translate enwiki protected page request: params: sourcelanguage: en targetlanguage: es title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein response: status: 200 headers: content-type: application/json - title: Translate enwiki protected page with multi-word title request: params: sourcelanguage: en targetlanguage: es title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein response: status: 200 headers: content-type: application/json /v2/page/{sourcelanguage}/{targetlanguage}/{title}/{revision}: get: tags: - Page content summary: Fetches segmented mediawiki page with revision parameters: - $ref: "#/components/parameters/sourcelanguage" - $ref: "#/components/parameters/targetlanguage" - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/revision" responses: 200: description: Success content: application/json: schema: type: object properties: sourceLanguage: type: string example: en title: type: string example: es revision: type: string example: 1234565 segmentedContent: type: string example: lorem ipsum 404: description: Not Found 500: description: Server Error x-amples: - title: Translate enwiki protected page with revision request: params: sourcelanguage: en targetlanguage: es title: User:BSitzmann_(WMF)/MCS/Test/Frankenstein revision: 1086816359 response: status: 200 headers: content-type: application/json /v2/translate/{from}/{to}: post: tags: - Machine translation description: Adapt the content for the target language wiki without performing any machine translation. parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" requestBody: content: application/json: schema: required: - html properties: html: type: string examples: hello world: value: { html:

hello world

} required: true responses: 200: description: Success 400: description: Invalid language code 404: description: Not Found 500: description: Server Error x-amples: - title: Machine translate an HTML fragment without provider, and an invalid language pair request: params: from: en to: qqq body: html:

Oxygen is a chemical element with symbol O and atomic number 8.

response: status: 400 /v2/translate/{from}/{to}/{mtprovider}: post: tags: - Machine translation summary: Translate the given content from source language to target language. description: Also adapt the content for the target language wiki. Some machine translation providers require an authorization header and it is forbidden to use them outside the Content Translation tool. parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/mtprovider" requestBody: content: application/json: schema: required: - html properties: html: type: string examples: hello world: value: { html:

hello world

} required: true responses: 200: description: Success 404: description: Not Found 500: description: Server Error x-amples: - title: Machine translate an HTML fragment using TestClient, adapt the links to target language wiki. request: params: from: en to: qqq mtprovider: TestClient body: html:

Oxygen is a chemical element with symbol O and atomic number 8.

response: status: 200 body: contents: /.+/ headers: content-type: application/json /v2/suggest/title/{title}/{from}/{to}: get: tags: - Suggestions summary: Suggest a target title for the given source title and language pairs parameters: - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" responses: 200: description: Success content: application/json: schema: type: object properties: history: type: array items: type: string description: Suggested title example: items: - Histoire - Historique 403: description: Authentication error. The default MT provider for the given language pair needs authorization, and the given JWT is invalid. 404: description: Not Found 500: description: Server Error x-amples: - title: Return the target language link for the given source title and language pairs description: The invalid JWT key is not used, as default MT provider doesn't need authentication request: headers: authorization: Test-auth params: title: Limonero from: es to: ca response: status: 200 body: sourceLanguage: es targetLanguage: ca sourceTitle: Limonero targetTitle: Llimoner headers: content-type: application/json - title: Return an authentication error HTTP status code, when default MT requires authentication and the given JWT is invalid description: The invalid JWT key is used, as default MT provider needs authentication request: headers: authorization: Test-auth params: title: Lemon from: en to: el response: status: 403 /v2/suggest/title/{title}/{from}/{to}/{mtprovider}: get: tags: - Suggestions summary: Suggest a target title for the given source title and language pairs with the given MT service parameters: - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/mtprovider" responses: 200: description: Success content: application/json: schema: type: object properties: history: type: array items: type: string description: Suggested title example: items: - Histoire - Historique 403: description: Authentication error. The default MT provider for the given language pair needs authorization, and the given JWT is invalid. 404: description: Not Found 500: description: Server Error x-amples: - title: Return the target language link for the given source title and language pairs description: The invalid JWT key is not used, as default MT provider doesn't need authentication request: headers: authorization: Test-auth params: title: Limonero from: es to: ca response: status: 200 body: sourceLanguage: es targetLanguage: ca sourceTitle: Limonero targetTitle: Llimoner headers: content-type: application/json - title: Return an authentication error HTTP status code, when default MT requires authentication and the given JWT is invalid description: The invalid JWT key is used, as default MT provider needs authentication request: headers: authorization: Test-auth params: title: Lemon from: en to: el response: status: 403 /v2/suggest/source/{title}/{to}: get: tags: - Suggestions summary: Suggest a source article to use for creating given article in given target language using translation parameters: - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/sourcelanguages" responses: 200: description: Success content: application/json: schema: type: object properties: suggestions: type: array items: type: object properties: pageId: type: integer example: 736 ns: type: integer example: 0 title: type: string example: Albert Einstein pageprops: type: object properties: wikibase_item: type: string example: Q937 thumbnail: type: object properties: source: type: string example: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Einstein_1921_by_F_Schmutzer_-_restoration.jpg/80px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg width: type: integer example: 80 height: type: integer example: 105 404: description: Not Found 500: description: Server Error x-amples: - title: Suggest a source title to use for translation request: params: to: ca title: Paneer query: sourcelanguages: en response: status: 200 body: suggestions: /^\[.+\]$/ headers: content-type: application/json /v2/suggest/sections/titles/{from}/{to}: get: tags: - Suggestions summary: Suggest target section titles based on provided source section titles. Titles are provided as URL params under the key "titles" parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/titles" responses: 200: description: Success content: application/json: schema: type: object properties: history: type: array items: type: string description: Suggested section title example: - Histoire - Historique 404: description: Not Found 500: description: Server Error x-amples: - title: Suggest target section titles for given source sections request: params: from: en to: es query: titles: References|Notes|External Links response: status: 200 body: References: [ Referencias, Bibliografía ] Notes: [ Referencias, Notas ] External Links: [ Enlaces externos ] headers: content-type: application/json /v2/suggest/sections/{title}/{from}/{to}: get: tags: - Suggestions summary: Suggest sections to translate from a source article to its corresponding article in target language. parameters: - $ref: "#/components/parameters/title" - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/include_section_sizes" responses: 200: description: Success content: application/json: schema: type: object properties: sections: type: object properties: sourceLanguage: type: string example: en sourceTitle: type: string example: Albert Einstein targetLanguage: type: string example: fr targetTitle: type: string example: Albert Einstein sourceSections: type: array items: type: string targetSections: type: array items: type: string present: type: object missing: type: object 404: description: Not Found 500: description: Server Error x-amples: - title: Suggest source sections to translate request: params: from: en to: ml title: Sitar response: status: 200 body: sections: sourceLanguage: /.+/ targetLanguage: /.+/ sourceTitle: /.+/ targetTitle: /.+/ present: /.+/ missing: /.+/ headers: content-type: application/json /v2/suggest/sections/{from}/{to}: get: tags: - Suggestions summary: Suggest sections to translate from source articles to their corresponding articles in target language, for a given list of articles. parameters: - $ref: "#/components/parameters/from" - $ref: "#/components/parameters/to" - $ref: "#/components/parameters/titles" - $ref: "#/components/parameters/include_section_sizes" responses: 200: description: Success content: application/json: schema: type: object properties: results: type: array items: type: object properties: sourceLanguage: type: string example: en sourceTitle: type: string example: Albert Einstein targetLanguage: type: string example: fr targetTitle: type: string example: Albert Einstein sourceSections: type: array items: type: string targetSections: type: array items: type: string present: type: object missing: type: object 400: description: Invalid language code 500: description: Server Error x-amples: - title: Suggest source sections to translate for multiple titles request: params: from: en to: ml query: titles: Pizza|Spaghetti include_section_sizes: true response: status: 200 body: results: - sourceLanguage: en targetLanguage: ml sourceTitle: Pizza targetTitle: /.+/ sourceSections: /.+/ targetSections: /.+/ present: /.+/ missing: /.+/ sourceSectionSizes: /.+/ - sourceLanguage: en targetLanguage: ml sourceTitle: Spaghetti targetTitle: /.+/ sourceSections: /.+/ targetSections: /.+/ present: /.+/ missing: /.+/ sourceSectionSizes: /.+/ headers: content-type: application/json # from routes/info.js /_info: get: tags: - Service information summary: Gets information about the service responses: 200: description: OK x-amples: - title: retrieve service info request: {} response: status: 200 headers: content-type: application/json body: name: /.+/ description: /.+/ version: /.+/ home: /.+/ /_info/name: get: tags: - Service information - Service name summary: Gets the name of the service responses: 200: description: OK content: application/json: schema: type: object properties: name: type: string example: { name: cxserver } x-amples: - title: retrieve service name request: {} response: status: 200 headers: content-type: application/json body: name: /.+/ /_info/version: get: tags: - Service information - Service version summary: Gets the running version of the service responses: 200: description: OK content: application/json: schema: type: object properties: version: type: string example: { version: 1.2.1 } x-amples: - title: retrieve service version request: {} response: status: 200 headers: content-type: application/json body: version: /.+/ /_info/home: get: tags: - Service information - Service homepage summary: Redirects to the home page responses: 301: description: Redirect x-amples: - title: redirect to the home page request: {} response: status: 301 components: parameters: domain: in: path name: domain required: true schema: type: string description: | Project domain for the requested data. language: in: path name: language required: true schema: type: string examples: English: value: en Spanish: value: es description: | Valid language code revision: in: path name: revision required: true schema: type: string description: | Revision Id example: 1274260387: value: 1274260387 title: in: path name: title required: true schema: type: string examples: Albert Einstein: value: Albert Einstein Roller Coaster: value: Roller coaster description: | Page title. Use underscores instead of spaces. Example: `Main_Page` spec: in: query name: spec required: false schema: type: string examples: spec: value: true doc: value: true fooo: value: true description: | Page title. Use underscores instead of spaces. Example: `Main_Page` prop: in: path name: prop required: true schema: type: string description: | Site info prop. from: name: from in: path description: The source language code examples: English: value: en Spanish: value: es schema: type: string required: true sourcelanguage: name: sourcelanguage in: path description: The source language code schema: type: string examples: English: value: en Spanish: value: es required: true to: name: to in: path description: The target language code schema: type: string examples: Spanish: value: es French: value: fr required: true targetlanguage: name: targetlanguage in: path description: The target language code schema: type: string examples: French: value: fr Spanish: value: es required: true titles: in: query name: titles description: List of source section titles separated by pipe ("|") delimiter, based on which target section suggestions will be given. Should be passed as array inside URL params (e.g. titles=test1|test2) schema: type: string required: true examples: History|Background: value: History|Background History: value: History Background: value: Background sourcelanguages: name: sourcelanguages in: query description: Comma-separated list of candidate source languages. By default English(en) is used as a source language unless that is the target language. schema: type: array items: type: string examples: en,es: value: en,es style: simple explode: true required: true word: name: word in: path description: The word to lookup schema: type: string required: true mtprovider: name: mtprovider in: path description: The machine translation provider id required: false schema: type: string enum: - MinT - Apertium examples: MinT: value: MinT tool: name: tool in: path description: The tool name schema: type: string enum: - mt examples: mt: value: mt required: true include_section_sizes: name: include_section_sizes in: query description: Whether to include section sizes in the response schema: type: boolean examples: true: value: true false: value: false required: false