API

Muut provides JavaScript API for developers so you are able to build awesome Muut extensions.

RESTful API

You can find out a lot more about our API on our documentation page.

RESTful API

/postcounts

A great example of our API in action is the postcounts GET.

postcounts is a simple GET request to query the number of posts in one or more specified paths. For paths to the root of a forum or to a channel, it returns the number of threads contained; For paths to a single thread, it returns the number of replies in the thread, excluding the seed post. If the path does not exist, it returns size of 0.

api.muut.com/postcounts?path=/forum&path=/forum/cat&path=/forum/cat:thread-id

Returns JSON:

{
  "/forum": {"size": 123},
  "/forum/cat": {"size": 23},
  "/forum/cat:thread-id": {"size": 2}
}

Examples:

As a RESTful method, you can directly call postcounts by visiting a URL in the browser, such as

https://api.muut.com/postcounts?path=/moot&path=/moot/open-word&path=/moot/open-word:you-spent-35-years-on-this&path=/goma

To make further use of the returned JSON data, you can take advantage of jQuery's getJSON() method with callback. The following code, for example, presents the JSON data in an HTML definition list.

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>Muut API / postcounts</title>
  <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
</head>

<body>
  <!-- container for results -->
  <dl id="results"></dl>

  <script>
    var url = "//api.muut.com/postcounts?path=/moot&path=/moot/open-word&path=/moot/open-word:you-spent-35-years-on-this&path=/goma";

    $.getJSON(url, function(json) {
     var results = $("#results");
     $.each(json, function(key, val) {
      results.append("<dt>" + key + "</dt><dd>" + val["size"] + "</dd>");
     });
    });
  </script>
</body>

</html>