An Application Programming Interface (API) is a connection between computers or between computer programs. I use the MediaWiki API mainly to check consistency between my online (lw) and local (llw) wikis.
My llw2lw script should keep things in sync unless I inadvertently forget or disrupt this myself (say, by updating something online directly without syncinc it locally).
In ~/comp/python/compare_llw_lw I have a series of scripts to make various types of comparisons between the two:
This is the main (first) script.
A second script, which makes the actual comparison.
This generates different_pages.txt and different_pages_with_revid.txt as well as non_file_differences.txt and real_content_differences.txt
They are the output files from the previous one-liners and scripts
Run the main revid comparison (fast, ~5–15 min depending on number of pages)
python compare_real_content.py
Exclude File:differences:
python3 -c '
import json
local = json.load(open("local_pages.json"))
online = json.load(open("online_pages.json"))
diff = sorted(t for t in set(local)|set(online) if local.get(t) != online.get(t) and not t.startswith("File:"))
print("Non-File differences:", len(diff))
print("\n".join(diff[:50]))
' > non_file_differences.txt
If I get rate-limited or timeouts in compare_real_content.py, then increase the time.sleep(0.7) to time.sleep(1.5).
This requires cloudflare to be disabled or to grant access (not under-attack mode).