Skip to content
remingtonwong edited this page Nov 24, 2011 · 13 revisions

GETTING REVISION HISTORY

http://en.wikipedia.org/w/api.php?rvprop=ids%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Csize%7Ctags&pageids=20660268&prop=revisions&action=query&format=xml&rvlimit=max

returns this: `

GETTING USER CONTRIBUTIONS

Article on how to do it: http://www.mediawiki.org/wiki/API:Usercontribs

Example query: http://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=Catrope&uclimit=3&ucdir=newer&format=xml

STUFF REMINGTON NEEDS TO FIGURE OUT HOW TO GET OVER THANKSGIVING

For a page id, get: revision history, article text, last n editors (n = 10?)

For a revision id: diff with prev revision, diff with current article

For a user: full contributions w/ diffs, (some kind of join)

users/userid/revid-prev users/userid/revid-cur

Naming

  • pageid-rev.xml

THANKSGIVING PUSH

The following information is also posted on the "API" GitHub Wiki page:

As you can see by the (thousands of) files I pushed, I downloaded all revision diffs (with previous) for two articles ("necrophilia" and "Google") and downloaded all revision diffs (with previous) associated with two users (SF007 and Hammersoft, the last two people to edit the Google article). A few things to know about file naming:

I ultimately decided to keep diffs for an article separate from diffs for a user. This means that:

Diffs for an article have paths like the following: revhistories/revision_diffs_by_page/PAGEID/PAGEID-REVISIONID-{prev, cur}.xml

Diffs for a user have paths like the following: revhistories/revision_diffs_by_user/USERNAME/PAGEID-REVISIONID-{prev, cur}.xml . Note that USERNAME is something like "Hammersoft" and not "123145". The reason I didn't use user id's is that the Wikipedia API for user contributions, unlike that for pages, does not accept id's. It only accepts usernames. Because each of these files contains one diff, and the file name contains only the page id and revision id, if you want to find out when a revision was made, you have to either look at the timestamp inside the file or "look it up" in the user contributions file, which I have downloaded to revhistories/user_contribs/USERNAME-*.xml. If you need something more convenient, let me know.

The stuff inside the tag in each diff file appears to be escaped HTML containing 's and 's. In other words, to meaningfully parse the insertions and deletions, you might need to feed the diff file to the XML parser, get the content of the tag, HTML-unescape the content, and then feed the unescaped content into another XML parser.

Clone this wiki locally