User:Jeropbrenda/Sandbox/Batchcomplete

From mediawiki.org

BatchComplete[edit]

When you make an API request using a generator together with properties, the API result may signal to continue because there are more properties to retrieve for the pages so far, or because there are more pages from the generator, or both. From version 1.25 onwards, the API returns a batchcomplete element to indicate that all data for the current "batch" of pages has been returned. This can be useful to avoid building a combined result set for thousands of pages when using a generator together with prop modules that may themselves need continuation.

Example[edit]

GET request to fetch pages whose title begins with T, with their links and backlinks.

Result
{
  "continue": {
    "lhcontinue": "TALKPAGENAMEE|862729",
    "continue": "||links"
  },
  "query": {
    "pages": {
      "620584": {
        "pageid": 620584,
        "ns": 0,
        "title": "T146965",
        "links": [{
          "ns": 0,
          "title": "Requests for comment/Deprecation policy"
        }],
        "linkshere": [{
          "pageid": 620586,
          "ns": 2600,
          "title": "Topic:Tcke1ac9vx7ju0de"
        }]
      },
      "799666": {
        "pageid": 799666,
        "ns": 0,
        "title": "TAIM",
        "links": [{
          "ns": 0,
          "title": "Technical Advice IRC Meeting"
        }]
      },
      "38304": {
        "pageid": 38304,
        "ns": 0,
        "title": "TALKPAGENAME",
        "links": [{
          "ns": 12,
          "title": "Help:Magic words"
        }],
        "linkshere": [{
          "pageid": 20139,
          "ns": 100,
          "title": "Manual:Title.php"
        }, {
          "pageid": 20584,
          "ns": 100,
          "title": "Manual:Title.php/ja"
        }, {
          "pageid": 221484,
          "ns": 100,
          "title": "Manual:Title.php/pt-br"
        }, {
          "pageid": 862729,
          "ns": 100,
          "title": "Manual:Title.php/en"
        }, {
          "pageid": 862953,
          "ns": 100,
          "title": "Manual:Title.php/da"
        }, {
          "pageid": 867928,
          "ns": 100,
          "title": "Manual:Title.php/es"
        }]
      },
      "99288": {
        "pageid": 99288,
        "ns": 0,
        "title": "TALKPAGENAMEE",
        "links": [{
          "ns": 12,
          "title": "Help:Magic words"
        }],
        "linkshere": [{
          "pageid": 20139,
          "ns": 100,
          "title": "Manual:Title.php"
        }, {
          "pageid": 20584,
          "ns": 100,
          "title": "Manual:Title.php/ja"
        }, {
          "pageid": 221484,
          "ns": 100,
          "title": "Manual:Title.php/pt-br"
        }]
      },
      "221693": {
        "pageid": 221693,
        "ns": 0,
        "title": "TALKSPACE",
        "links": [{
          "ns": 12,
          "title": "Help:Magic words"
        }]
      },
      "221694": {
        "pageid": 221694,
        "ns": 0,
        "title": "TALKSPACEE",
        "links": [{
          "ns": 12,
          "title": "Help:Magic words"
        }]
      },
      "589021": {
        "pageid": 589021,
        "ns": 0,
        "title": "TCG",
        "links": [{
          "ns": 0,
          "title": "Technical Collaboration Guidance"
        }]
      },
      "798097": {
        "pageid": 798097,
        "ns": 0,
        "title": "TEC",
        "links": [{
          "ns": 0,
          "title": "Wikimedia Technology/Annual Plans"
        }]
      },
      "83746": {
        "pageid": 83746,
        "ns": 0,
        "title": "TEI",
        "links": [{
          "ns": 102,
          "title": "Extension:TEITags"
        }]
      },
      "96305": {
        "pageid": 96305,
        "ns": 0,
        "title": "TEX Editor/Code",
        "links": [{
          "ns": 102,
          "title": "Extension:TEX Editor/Code"
        }]
      }
    }
  }
}

From the response, only three backlinks for "TALKPAGENAMEE" have been returned. If you send a GET request to fetch backlinks for "TALKPAGENAMEE" you will see that there are more than three, hence batchcomplete is not included in the response because there's more data to be returned for this batch.

The next continuation will return more links until eventually all the links and backlinks for each of the 10 pages in this batch will have been output, at which point the response will include batchcomplete to indicate that all the data for this batch has been output. The continuation from the response with batchcomplete will begin returning data for the next set of 10 pages.