Get revscoring damaging prediction

POST /service/lw/inference/v1/models/{wiki}-damaging:predict

Get a score from the Revscoring Damaging model (previously hosted on ORES) for a given Wiki revision id.

Examples

curl

Anonymous access

# Get a score from the Revscoring Damaging model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-damaging:predict -X POST -d '{"rev_id": 12345}' -H "Content-type: application/json"

Logged in access

# Get a score from the Revscoring Damaging model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-damaging:predict -X POST -d '{"rev_id": 12345}' -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-type: application/json"

Python

# Python 3
# Get a score from the Revscoring Damaging model for the revision 12345 of English Wikipedia.

import json
import requests

use_auth = False
inference_url = 'https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-damaging:predict'

if use_auth:
  headers = {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)',
      'Content-type': 'application/json'
  }
else:
  headers = {}
data = {"rev_id": 12345 }
response = requests.post(inference_url, headers=headers, data=json.dumps(data))
print(response.json())

JavaScript

/*
 Get a score from the Revscoring Damaging model for the revision 12345 of English Wikipedia.
*/

const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-damaging:predict";
const accessToken = "YOUR_ACCESS_TOKEN";
const appName = "YOUR_APP_NAME";
const email = "YOUR_EMAIL_OR_CONTACT_PAGE";
let headers = new Headers({
    "Content-Type": "application/json",
    "Authorization": "Bearer " + accessToken,
    "Api-User-Agent": appName + " ( " + email + " )"
});
let data = {"rev_id": 12345 };

fetch(inferenceUrl, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));

URI Parameters

wiki

required

Wiki code:arwiki (Arabic), bswiki (Bosnian), cawiki (Catalan), cswiki (Czech), dewiki (German), enwiki (English), eswiki (Spanish), eswikibooks (Spanish Wikibooks), eswikiquote (Spanish Wikiquote), etwiki (Estonian), fawiki (Persian), fiwiki (Finnish), frwiki (French), hewiki (Hebrew), hiwiki (Hindi), huwiki (Hungarian), itwiki (Italian), jawiki (Japanese), kowiki (Korean), lvwiki (Latvian), nlwiki (Dutch), nowiki (Norwegian), plwiki (Polish), ptwiki (Portuguese), rowiki (Romanian), ruwiki (Russian), sqwiki (Albanian), srwiki (Serbian), svwiki (Swedish), ukwiki (Ukrainian), wikidatawiki (Wikidata) or zhwiki (Chinese).

POST Parameters

rev_id

required

Wiki Revision id: integer related to a certain revision id for the Wiki set in the URI parameter.
extended_output Whether or not the response should include the extended output of the model (like the list of features used etc..). Either true or false. Default: false

Responses

200 Success: Revision id found. Returns a Revscoring score object.
Example
{
  "enwiki": {
    "models": {
      "damaging": {
        "version": "0.5.1"
      }
    },
    "scores": {
      "12345": {
        "damaging": {
          "score": {
            "prediction": false,
            "probability": {
              "false": 0.744276020191829,
              "true": 0.255723979808171
            }
          }
        }
      }
    }
  }
}