Get content translation recommendations
| GET | /service/lw/recommendation/v1/api/
|
|---|
The service recommends articles to translate from one language to another. Check the documentation for more info.
Examples
curl
Anonymous access
# Anonymous request
$ curl "https://api.wikimedia.org/service/lw/recommendation/v1/api/?s=en&t=fr&n=3&article=Apple"
Logged in access
# Authenticated request using Bearer token
$ curl "https://api.wikimedia.org/service/lw/recommendation/v1/api/?s=en&t=fr&n=3&article=Apple" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-type: application/json"
Python
# Python 3
import json
import requests
use_auth = False
inference_url = "https://api.wikimedia.org/service/lw/recommendation/v1/api/?s=en&t=fr&n=3&article=Apple"
if use_auth:
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"User-Agent": "YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)"
}
else:
headers = {}
response = requests.get(inference_url, headers=headers)
print(response.json())
JavaScript
const inferenceUrl = "https://api.wikimedia.org/service/lw/recommendation/v1/api/?s=en&t=fr&n=3&article=Apple";
const accessToken = "YOUR_ACCESS_TOKEN";
const appName = "YOUR_APP_NAME";
const email = "YOUR_EMAIL_OR_CONTACT_PAGE";
let headers = new Headers({
"Authorization": "Bearer " + accessToken,
"User-Agent": appName + " ( " + email + " )"
});
fetch(inferenceUrl, {
method: "GET",
headers: headers
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));
Responses
| 200 | Success: Returns a content translation recommendations object.
Example
[
{
"pageviews": 495,
"title": "EverCrisp",
"wikidata_id": "Q65057164",
"rank": 499
},
{
"pageviews": 114,
"title": "Kaolin_spray",
"wikidata_id": "Q6366155",
"rank": 496
},
{
"pageviews": 1455,
"title": "Durio_zibethinus",
"wikidata_id": "Q1135236",
"rank": 493
}
]
|
|---|