Jump to content

User:APaskulin (WMF)/Sandbox/Reference

From mediawiki.org

This page is a staging area for documentation for endpoints in the coredev namespace of the MediaWiki REST API.

Contributions

[edit]
MediaWiki version:
1.36

Contribution object

[edit]

The contribution object represents an edit to a page.

Example

[edit]
{
  "id": 399173,
  "comment": "Added a section to test comparing revisions",
  "timestamp": "2019-10-17T17:59:54Z",
  "delta": 35,
  "size": 27161,
  "tags": [
    {
      "name": "visualeditor-wikitext",
      "description": "2017 source edit"
    }
  ],
  "type": "revision",
  "page": {
    "id": 1457,
    "key": "Dog",
    "title": "Dog"
  }
}

Schema

[edit]
id

required | integer

Revision identifier
comment

required | string

Comment or edit summary written by the editor. For revisions without a comment, the API returns null or "".
timestamp

required | string

Time of the revision in ISO 8601 format
delta

required | integer

Number of bytes changed, positive or negative, between a revision and the preceding revision (example: -20). If the preceding revision is unavailable, the API returns null.
size

required | integer

Size of the revision in bytes
tags

required | array

Array of tag objects associated with the revision, including:
  • name (string): Tag name
  • description (string): Tag description
type

required | string

Type of contribution, always revision
page

required | object

Object containing information about the page, including:
  • id (integer): Page identifier
  • key (string): Page title in URL-friendly format
  • title (string): Page title in reading-friendly format

Get contributions

[edit]
Route /user/{user}/contributions Content type application/json
Method GET Returns Contribution set

Returns information about contributions made by a user, starting with the most recent contribution. The response includes API routes for the next oldest, next newest, and latest contribution sets, letting you scroll through contribution history. This endpoint supports listing contributions for a specific username or IP address (using /user/{user}/contributions) or for the logged-in user (using /me/contributions).

Examples

[edit]
https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/user/Apaskulin/contributions?limit=10&segment=after|7C20191017175954&tag=visualeditor-wikitext

Parameters

[edit]
user

required | path

Username or IP address of the contributing user
me

optional | path

In place of /user/{user}, this endpoint supports /me as a path alias to get contributions made by the logged-in user. For example: https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/me/contributions
segment

optional | query

This parameter lets you filter by contributions that occurred before or after a given time. To use this parameter, include either before or after followed by a pipe character (|) and the marker to use to filter the results. This parameter accepts either a timestamp (ISO 8601 or MediaWiki Timestamp) or revision ID as a marker.
limit

optional | query

Maximum number of contributions to return, between 1 and 100. Default: 20
tag

optional | query

Tags are annotations associated with a revision or log entry. This parameter allows you to filter contributions by a tag, which can help you see your participation in a project or using a specific tool. To see which tags are available in a wiki, visit the Special:Tags page. (For example, Special:Tags on mediawiki.org.)

Responses

[edit]
200 Success: Contributions found. Returns a contribution set.
200 Success: No contributions found. Returns a contribution set with an empty contributions array.
400 Invalid segment or limit parameter
401 /me path element not accessible by anonymous user. Log in to use this path.
404 User not found

Response schema

[edit]
latest

required | string

API route to get the latest contributions
older

required | string

API route to get the prior contributions, or null if no older contributions exist
newer

required | string

API route to get the following contributions. This property always contains a value, even if no newer contributions exist.
contributions

required | array

Array of contribution objects

Count contributions

[edit]
Route /user/{user}/contributions/count Content type application/json
Method GET Returns count

Returns the number of contributions made by a user. This endpoint supports contributions counts for a specific username or IP address (using /user/{user}/contributions/count) or for the logged-in user (using /me/contributions/count).

Examples

[edit]
https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/user/Apaskulin/contributions/count?tag=visualeditor-wikitext

Parameters

[edit]
user

required | path

Username or IP address of the contributing user
me

optional | path

In place of /user/{user}, this endpoint supports /me as a path alias to count contributions made by the logged-in user. For example: https://en.wikipedia.beta.wmflabs.org/w/rest.php/coredev/v0/me/contributions/count
tag

optional | query

Tags are annotations associated with a revision or log entry. This parameter allows you to filter the contribution count by a tag, which can help you measure your participation in a project or using a specific tool. To see which tags are available on a wiki, visit the Special:Tags page. (For example, Special:Tags on mediawiki.org.)

Responses

[edit]
200 Success: User found
401 /me path element not accessible by anonymous user. Log in to use this path.
404 User not found

Response schema

[edit]
count

required | integer

Total number of contributions made by the user