See [[mw:API]]. Usually used with [[JSON]] format.
===HTML===
You could fetch the whole article page or use <code>&action=render</code> URL parameter to get the content without all the menus ([{{fullurl:{{FULLPAGENAME}}|action=render}} example]). Also see [[mw:Manual:Parameters to index.php|Parameters to index.php]].
The result you could treat as a text but it's usually convenient to parse it as HTML document, e.g. using DOMParser object <small>(examples needed)</small>.
===Wiki code===
To get the wiki code you use <code>&action=raw</code> URL parameter ([{{fullurl:{{FULLPAGENAME}}|action=raw}} example]).
The result you treat as a text.
===Preview===
Sometimes you might want to use preview. For example, [[Special:Prefixindex]] won't work with <code>&action=render</code>. To get rid of the unnecessary menus you could submit <tt><nowiki>{{Special:Prefixindex/somepage}}</nowiki></tt> for a preview and get a "clean" list (nevertheless, it's better to use API for prefix index)