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

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


 * 1) Get the content of a page through.
 * 2) Get parsed content of a page through.
 * 3) Get plain text or limited HTML extracts of a given page through.

Method 1: Get the content of a page through API: Revisions
This can be done by specifying the parameter  of the page. The retrieved content is in the form of wikitext.

Example
GET request to obtain the retrieved wikitext content of the page Pet door.

Method 2: Get the parsed content of a page by API: Parse
This can be done by:


 * 1) Specifying a page or revision using the parameter  . The retrieved content is in the form of HTML.
 * 2) Specifying parameter   as wikitext to get the original wikitext that was parsed. The retrieved content is in the form of wikitext.

Example 1
GET request to get parsed content of a page: Pet door.

Response
 ^ "World's first Passive House-certified pet door unveiled at Ecobuild 2014". www.gizmag.com. Retrieved 2016-07-07.  .mw-parser-output cite.citation{font-style:inherit}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration{color:#555}.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration span{border-bottom:1px dotted;cursor:help}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output code.cs1-code{color:inherit;background:inherit;border:inherit;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;font-size:100%}.mw-parser-output .cs1-visible-error{font-size:100%}.mw-parser-output .cs1-maint{display:none;color:#33aa33;margin-left:0.3em}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration,.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-right{padding-right:0.2em}   ^ "Automated Pet Doors&#160;: pet door". Retrieved 2016-07-07.  <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> <li id="cite_note-3"> ^</a> <cite class="citation web">"PetWALK Automatic Pet Door Prevents Wet Paw Marks Around The Home"</a>. Ubergizmo. 2014-03-13 . Retrieved 2016-07-07. <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=Ubergizmo&amp;rft.atitle=PetWALK+Automatic+Pet+Door+Prevents+Wet+Paw+Marks+Around+The+Home&amp;rft.date=2014-03-13&amp;rft_id=http%3A%2F%2Fwww.ubergizmo.com%2F2014%2F03%2Fpetwalk-automatic-pet-door-prevents-wet-paw-marks-around-the-home%2F&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3APet+door" class="Z3988"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> <li id="cite_note-4"> ^</a> Oxford English Dictionary (full ed.), 2005. </li> <li id="cite_note-NatGeo_2004-5"> ^</a> <cite class="citation web">"Oldest Known Pet Cat? 9500-year-old Burial Found on Cyprus"</a>. National Geographic News. National Geographic Society. April 8, 2004. Retrieved March 6, 2007. <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=National+Geographic+News&amp;rft.atitle=Oldest+Known+Pet+Cat%3F+9500-year-old+Burial+Found+on+Cyprus&amp;rft.date=2004-04-08&amp;rft_id=http%3A%2F%2Fnews.nationalgeographic.com%2Fnews%2F2004%2F04%2F0408_040408_oldestpetcat.html&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3APet+door" class="Z3988"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> <li id="cite_note-6"> ^</a> <cite class="citation web">Anonymous ("The Country Parson") (1863). E. H. Sears &amp; Rufus Ellis (ed.). "Random Readings: Philosophy and Common Sense"</a>. The Monthly Religious Magazine. Boston, MA: Leonard C. Bowles Press. p.&#160;298. <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.genre=unknown&amp;rft.jtitle=The+Monthly+Religious+Magazine&amp;rft.atitle=Random+Readings%3A+Philosophy+and+Common+Sense&amp;rft.pages=298&amp;rft.date=1863&amp;rft.au=Anonymous+%28%22The+Country+Parson%22%29&amp;rft_id=https%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DPXYUAAAAYAAJ%26pg%3DPA298&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3APet+door" class="Z3988"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> <li id="cite_note-7"> ^</a> Brodetsky, S. (2007) [first pub. 1927]. Sir Isaac Newton. Upton Press. p. 100. <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/>ISBN</a>&#160;1406769991</a>. </li> <li id="cite_note-8"> ^</a> More, Louis Trenchard (1937). Isaac Newton: a Biography. C. Scribner's Sons. </li> <li id="cite_note-9"> ^</a> Wright, J. F. M. (1827). Alma Mater. Volume 1. p. 17. </li> <li id="cite_note-10"> ^</a> <cite class="citation web">"Petplan Pet Census 2011"</a> (PDF). Petplan. p.&#160;15. Retrieved September 11, 2012. <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=Petplan+Pet+Census+2011&amp;rft.pages=15&amp;rft.pub=Petplan&amp;rft_id=http%3A%2F%2Fwww.petplan.co.uk%2Fpetcensus%2Fcensusinfo.pdf&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3APet+door" class="Z3988"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> <li id="cite_note-11"> ^</a> <cite class="citation web">Woods, Amanda. "7 Important Measures to Pet Proof Your Home"</a>. Retrieved 23 August 2017. <span title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=unknown&amp;rft.btitle=7+Important+Measures+to+Pet+Proof+Your+Home&amp;rft.aulast=Woods&amp;rft.aufirst=Amanda&amp;rft_id=https%3A%2F%2Fmedium.com%2F%40woodsamanda399%2F7-important-measures-to-pet-proof-your-home-bdd3e33ae4c8&amp;rfr_id=info%3Asid%2Fen.wikipedia.org%3APet+door" class="Z3988"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r886058088"/> </li> </ol>

Example 2
GET request to get the original wikitext content of a page: Pet door.

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 request to extract 10 sentences from the page: Pet door.

Additional notes
The content extracted directly from Wikipedia can be inserted into any MediaWiki wiki through. The content extracted comes in the form of limited wikitext, omitting leading templates, links to files or pages.