On Wed, Aug 3, 2016 at 4:44 AM, Strainu strainu10@gmail.com wrote:
Hi,
Short answer: The API does not seem to directly provide such info, but you could use action=compare, then search for class="diff-lineno" and divide by 2 (it appears once on each side of the diff).
Do note that the question you ask is not very well defined. The method above will give you the number of chunks the diff engine displays, which can be different from what you consider as a modification. For instance https://ro.wikipedia.org/w/api.php?action=compare&fromrev=9648318&to... shows 1 chunk, but there is a modified line and an added line (the category), which you might consider as 2 different modifications. You need to clearly set the expectations before searching for a solution.
fwiw, Pywikibot has an APISite method "compare" to fetch the MediaWiki diff
https://doc.wikimedia.org/pywikibot/api_ref/pywikibot.html#pywikibot.site.AP...
and another function "html_comparator" to convert the MediaWiki diff into something a bit more usable for simple uses
https://doc.wikimedia.org/pywikibot/api_ref/pywikibot.html#pywikibot.diff.ht...
We have one unit test that puts these two functions together in a hopefully understandable fashion
https://github.com/wikimedia/pywikibot-core/blob/master/tests/diff_tests.py#...