Kuma: Cool URL tricks

If you’re fiddling with automation, or want to be able to pull information out of the Mozilla Developer Network wiki, there are some helpful queries you can do with URLs that may help you out. Today, I’m going to share those.

The Kuma API

While we don’t yet have a writable API (we know this is a problem, and a design for it is underway), we do have various ways to access useful information about pages in the wiki.

Command Description
?raw Instructs Kuma to return the raw content of the page, without any of the skin material, such as the headers, footers, and so forth. This does not execute templates or scripts. For example, https://developer.mozilla.org/en-US/docs/HTML/HTML5?raw
&macros Instructs Kuma to execute all the templates in the page. For example: https://developer.mozilla.org/en-US/docs/HTML/HTML5?raw&macros
&include Tells Kuma to strip out any blocks that have the class “noinclude” on them. This is useful to get the output as it would appear when included in another page, rather than as a standalone page. Often this will remove sample code and the like (although not always).
&section=[section-id] Instructs Kuma to return the content from only the section with the specified anchor name; for example: https://developer.mozilla.org/en-US/docs/HTML/HTML5?raw&section=Introduction_to_HTML5
$json Tells Kuma to describe the page in a JSON object; this object is essentially the same one you would get using the KumaScript routine wiki.getPage(). For example: https://developer.mozilla.org/en-US/docs/HTML/HTML5$json

These offer a lot of capability, and hopefully will be useful for people building developer tools and other utilities.

Kuma feeds

In addition to the API described above, we also offer a number of feeds. There will likely be more in the future, and some of these are still something of a work in progress, but this information may still be useful for you.

All feeds start with the string “https://developer.mozilla.org/<locale>/docs/feeds/<format>/”, where <locale> is one of the standard locale strings, such as “en-US”, “ja”, and so forth. Note that at present, the locale you specify doesn’t impact the output, but it may eventually do so (indeed, I hope it will). <format> is one of “atom”, “rss”, or “json”.

Feed Description
all All recently changed articles, in order of modification date. This includes newly created articles. All changes are combined into one entry in the feed for each article.
revisions Each revision made to an article, in order by modification date, including newly created articles. Each revision has a separate entry in the feed.
tag/<tagname> Recently changed articles, in order by modification date. Only articles that have the specified tag are included in the feed.
files Recently changed or uploaded files.
needs-review[/<reviewtype>] A list of articles that have the specified review request checked, or all articles with a review requested if you don’t specify a review type. The review type can be one of “tech”, “editorial”, or “kumascript”.

So, for example, you can get an atom format feed of recently changed articles tagged with “JavaScript” thusly: https://developer.mozilla.org/en-US/docs/feeds/atom/tag/JavaScript.

Wrapping up

Hopefully these are useful! There’s more to come, but these are a great start! Enjoy!


4 comments

  1. les orchard

    One correction – for feeds, the common base URL is this:

    https://developer.mozilla.org//docs/feeds//

    Where is the locale (eg. en-US, fr, ja) and is one of rss, atom, or json. And when the format is “json”, the URLs accept a ?callback parameter to wrap the data in a function call, JSONP-style.

    For example:
    https://developer.mozilla.org/en-US/docs/feeds/atom/tag/JavaScript
    https://developer.mozilla.org/en-US/docs/feeds/rss/tag/JavaScript
    https://developer.mozilla.org/en-US/docs/feeds/json/tag/JavaScript?callback=processfeed

    August 9th, 2012 at 06:59

  2. les orchard

    Crap. Comments ate my placeholders. I meant this base URL:

    https://developer.mozilla.org/{locale}/docs/feeds/{format}/

    August 9th, 2012 at 07:00

  3. Salman Abbas

    Pretty cool. How about enabling CORS maybe :P

    August 9th, 2012 at 18:46

    1. Eric Shepherd

      We talked about CORS this week. I don’t know when it will happen buti expect it will eventually.

      August 9th, 2012 at 20:31

Comments are closed for this article.