Parsoid/API

Parsoid converts MediaWiki's Wikitext to XHTML5 + RDFa and back.

A production version of Parsoid on the Wikimedia cluster can be accessed at http://parsoid-lb.eqiad.wikimedia.org/.

Common HTTP headers supported in all entry points

 * Accept-encoding : Please accept gzip.
 * Cookie : Cookie header that will be forwarded to the API. Makes it possible to use Parsoid with private wikis. Setting a cookie implicitly disables all caching for security reasons, so do not send a cookie for public wikis if you care about caching.

v2 API
Parsoid gained a "v2" API in December 2014 to act as middleware behind RESTBase entry points. The spec for it is at. The new entry points are of the form



is, roughly, the hostname of the wiki, rather than the wiki id {prefix} in v1 entry points.

The main addition is a new format, that responds to a request with a JSON structure containing separate   data for clean roundtripping between HTML and wikitext and a   key with slimmer HTML of {title} without   attributes.

For example, compare the value of html.body in
 * http://parsoid-lb.eqiad.wikimedia.org/v2/en.wikipedia.org/pagebundle/Siskiwit_Lake/650380826

with the HTML of
 * http://parsoid-lb.eqiad.wikimedia.org/enwiki/html/Siskiwit_Lake?oldid=650380826

v1 API entry points
The  in these examples refers to the configured wiki id as available in the siteinfo API request. Examples: 'enwiki', 'frwiki', 'dewiki' etc. refers to the canonical page name with spaces replaced with underscores. Examples: 'Main_Page', 'Barack_Obama' etc.


 * : Get HTML for a given page revision. Example: /enwiki/Main_Page?oldid=598252063.
 * Convert passed-in wikitext or html
 * The {page} path component should be provided if available. Both it and the  parameter are needed for clean round-tripping of HTML retrieved earlier with.
 * HTML to Wikitext
 * oldid
 * the revision id this is based on (if any)
 * html
 * HTML to serialize to wikitext
 * Wikitext to HTML
 * wt
 * Wikitext to parse to HTML
 * body (optional) : boolean flag, only return the HTML body.innerHTML instead of a full document
 * For example, using the cURL command-line tool $ curl localhost:8000/localhost/Main_Page -d wt="Hello world" -d body=1
 * For example, using the cURL command-line tool $ curl localhost:8000/localhost/Main_Page -d wt="Hello world" -d body=1

Convenience method:
 * : Get HTML for the latest page revision, redirects to the full  form.

The Parsoid service provides additional form-based debugging tools at, e.g. http://parsoid-lb.eqiad.wikimedia.org/. These are not part of the API, and may change or disappear at any time.