Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
About
People
Publications
Teaching
Resources
Research Blog
Wiki Functions
Recent changes
Help
Licensing
Page
Discussion
Edit
View history
Editing
DS4UX (Spring 2016)/Wikipedia API
(section)
From CommunityData
Jump to:
navigation
,
search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== What kind of data can you get from the MediaWiki API? == * As you probably already know, Wikipedia is a website that anyone can edit. * Wikipedia runs software called MediaWiki which exists on many other wikis. * A wiki is a type of website (like "blog") === Wikipedia basics: edits, pages, and editors === Every time an editor (like you!) makes an edit (or ''revision'') to a page on Wikipedia, some information about that edit (called metadata) is saved, along with the text of the page after the edit was made. All of the edits ever made to any page on Wikipedia can be viewed in that page's ''revision history''. When you click the 'view history' tab at the top-right of any Wikipedia article to see metadata about all the edits made to that article, in reverse chronological order. You can also click links on this list to see more information about what the page looked like after the edit, to see what was changed, and to find out more about the person who made the edit. You can access all of this information (and much more) by ''querying'' the MediaWiki API. Go to the [http://en.wikipedia.org/w/api.php api page] on any wiki to show API documentation or check out the [https://www.mediawiki.org/wiki/API:Main_page main documentation for the MediaWiki API on the MedaiWiki website]. In the sections below, I will describe some types of metadata that you can gather about edits, editors, and pages through the API. === Revision metadata === You can get metadata about a particular revision through the <code>rvprop=</code> parameter. Here are some of the things you can get ([Click here for the full list https://www.mediawiki.org/wiki/API:Revisions]): * ids: :* revid: current revision of the page :* parentid: previous revision of the page * timestamp: The date and time the revision was made * user: The username of the editor who made the revision (or their IP address, if they aren't logged in) * userid: A unique id of the editor * comment: The edit comment the editor made when they committed the revision * size: The size of the revision text in bytes. * content: The revision content. * tags: Any tags for this revision, such as whether the edit was made on a mobile device === Editor metadata === * usercontribs: Get the list of contributions made by a user: https://www.mediawiki.org/wiki/API:Usercontribs * users: Returns information about a list of users: https://www.mediawiki.org/wiki/API:Users === Page text and metadata === * categories: categories a page is in: https://www.mediawiki.org/wiki/API:Categories#Parameters * contributors: people who have edited a page: https://www.mediawiki.org/wiki/API:Contributors * images: images (and audio + video) files on a page: https://www.mediawiki.org/wiki/API:Images * links: the links on a page: https://www.mediawiki.org/wiki/API:Links * categorymembers: all of the pages that are in a particular category: https://www.mediawiki.org/wiki/API:Categorymembers * pageprops: basic information about the page: https://www.mediawiki.org/wiki/API:Pageprops === Examples of API queries === * looking at the images within a page (try this with another city by changing the value of <code>titles=</code>!): http://en.wikipedia.org/w/api.php?action=query&titles=Seattle&prop=images&imlimit=20&format=jsonfm :* change the city with a custom URL * getting individual users' edit counts: http://en.wikipedia.org/w/api.php?action=query&list=users&ususers=Benjamin_Mako_Hill|Jtmorgan|Moonriddengirl|Keilana&usprop=editcount&format=jsonfm * get the content of the main page http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content There are several other interesting examples [[Sample_Wikipedia_API_queries|available on the Sample API queries page]].
Summary:
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see
CommunityData:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:
Cancel
Editing help
(opens in new window)
Tools
What links here
Related changes
Special pages
Page information