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

There are basically 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 explicitely using text, title, 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 pageids.
 * 2) Get revisions for one given page, by using titles or pageids with start, end, or limit.
 * 3) Get data about a set of revisions by setting their IDs with revids.

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

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

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. \n\n=== Uses for the MediaWiki Action API === \n\n \n* Monitor a MediaWiki installation\n* Create a bot to maintain a MediaWiki installation \n* 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 data-format>Special:MyLanguage/API:Data formats|input and output formats The page about errors>Special:MyLanguage/API:Errors and warnings|errors and warnings The page about 1>Special:MyLanguage/API:Etiquette|etiquette Any policies that apply to the wiki you want to access, such as Wikimedia Foundation wikis\' 1>wmf:Special:MyLanguage/Terms of Use|terms of use, 2>wmf:Special:MyLanguage/trademark policy|trademark policy. \n\n\nThese terms apply to you when you access or edit using the API, just as they do when you use your web browser.

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 1>Special:MyLanguage/API:Web APIs hub|Web APIs hub for information on other APIs for Wikimedia project data and their usage. \n\n== Code stewardship==\n\n\n\n\n\n\n\n '}}}]

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, pageid, or oldid.
 * 2) Specify content explicitly, using text, title, revid, and contentmodel.
 * 3) Specify only a summary to parse. 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-