From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

This page shows how the bot can add/change langlinks on wikidata.


The bot wants to create an interwikigroup of four pages (all having different/localized titles in this example):


  • The bot is logged in and sends the required cookie data within each request.
  • Always use post request. Only action and format are part of the url.
  • All data is send urlencoded, which is not done for human readability at the examples below.
  • +\ is used as token in all examples, but a token returned by a previous request is used instead.

Step 1[edit]

Check which wiki can be added to wikidata.

No api request available. incubator-grc and commonswiki not available at the moment.

Step 2[edit]

The bot wants to know if any of these pages are already contained within an item.

One request for every pages needed
    read itemid from /api/items/item/@id (attribute id is missing if no connected item exists and attribute missing exists)

Step 3[edit]

Modify WikiData Items

Scenario a[edit]

None of these pages is connected to a item.

Request Token
    read token: /api/wbsetitem/@setitemtoken
Create a new item conating all pages

Scenario b[edit]

Some of these pages (dewiki) are already connected to one item (id 111) and the rest (enwiki) should be added to this item.

Request Token
    read token: /api/wbsetitem/@setitemtoken
Create a new item conating all pages

Scenario c[edit]

Pages are connected to different items and should be forced to use the same icon (forced regrouping after review by bot operator)


This table shows the number of need http requested needed to add/chage an interwikigroup of #pages Pages. For scenario b/c half of the pages are already connected to a wikidata item.

#pages #api-requests
a b c