User:User:Dikshagupta99/Sandbox/API:Get the contents of a page

There are three main methods for retrieving page contents via the API:


 * 1) Get data about the set of pages by setting titles or page ids(for retrieving wikitext)
 * 2) Specify content explicitly using text, title, revision id(revid) and content model(for retrieving parsed content)
 * 3) Return plain text or limited HTML extracts of a given page.

Method 1: Get revised page data from API: Revisions
There are several ways of getting the revised data:


 * 1) Get data about a set of pages (last revision), by setting titles or page ids.
 * 2) Get revisions for one given page, by using titles or page ids with start, end, or limit.
 * 3) Get data about a set of revisions by setting their IDs with revision ids.

Example 1
The below GET request is to obtain revised data of the page.

Response
{| class="wikitable" !API Endpoint !Wiki
 * + Examples of Wikimedia Wiki Endpoints
 * MediaWiki API|-
 * Meta-Wiki API
 * English Wikipedia API|-
 * Dutch Wikipedia API|-
 * Wikimedia Commons API
 * Test Wiki API|}
 * Dutch Wikipedia API|-
 * Wikimedia Commons API
 * Test Wiki API|}
 * Wikimedia Commons API
 * Test Wiki API|}
 * Test Wiki API|}

Introduction
The MediaWiki action API is a web service that allows access to some wiki-features like authentication, page operations, and search. It can provide meta information about the wiki and the logged-in user.

Uses for the MediaWiki Action API
Monitor a MediaWiki installation Create a bot to maintain a MediaWiki installation Log into a wiki, access data, and post changes by making HTTP requests to the web service

Getting started with MediaWiki action API
Before you start using the MediaWiki action API, you should review the following pages: The faq>Special:MyLanguage/API:FAQ|FAQ. The page about [[Special:MyLanguage/API:Data formats The page about [[Special:MyLanguage/API:Errors and warnings The page about [[Special:MyLanguage/API:Etiquette Any policies that apply to the wiki you want to access, such as Wikimedia Foundation wikis\' [[wmf:Special:MyLanguage/Terms of Use [[wmf:Special:MyLanguage/trademark policy These terms apply to you when you access or edit using the API, just as they do when you use your web browser.
 * input and output formats]]
 * errors and warnings]]
 * etiquette]]
 * terms of use]],
 * trademark policy]].

Other APIs
If you do not find what you are looking for in this API documentation, there are many other APIs related to Wikimedia projects. See the [[Special:MyLanguage/API:Web APIs hub for information on other APIs for Wikimedia project data and their usage.
 * Web APIs hub]]

Code stewardship
{{feedback } }
 * author = Core Platform Team
 * irc = mediawiki-core\n|phab = mediawiki-api

'}}}]

For the sample codes, view

Method 2: Get the content of a page by API: Parsing_wikitext
There are several ways to specify the text to parse:


 * 1) Specify a page or revision, using page, page id, or old id.
 * 2) Specify content explicitly, using text, title, revision id, and content model.
 * 3) Specify only a summary to parse. property(prop) should be given an empty value.

For more details regarding API:Parsing_wikitext view

Example
GET request to get parsed content of a page:Main_page

Method 3: Get the content of the page using Extension: TextExtracts#API
The TextExtracts extension provides an API which allows to retrieve plain-text or limited HTML extracts of page content.

Example
Get a 100-character extract:

Download Extension
To download extension view-