JavaScript API

The JavaScript API is built for web apps running in a browser. It allows quick access to MindMeister's Rest API using the implicit flow of the OAuth 2.0 protocol.

To get started a client application has to be registered. See Register your Application for details. Make sure that the URL of your web app is added as a redirect URI, otherwise the authorization step will fail.

Next, add the following line to the HTML header of your web app with the client id, that was created in the previous step.

<script src="https://www.mindmeister.com/api/v2/js/api.js?client_id=[Client_ID]"></script>

After including the JavaScript source file, you have access to the global ML object. It represents the interface to the entire JavaScript API of MindMeister.

Authorization

Before any API resource can be accessed, the resource owner, so the user has to grant permissions. This is done through ML.authorize(). It opens the OAuth 2.0 consent screen in a separate window and initiates the OAuth 2.0 implicit flow.

After the user granted permissions for the requested scope, the window is closed automatically and the callback onSuccess is called. In case of a failure the callback onError is called.

After authorization an access token is received and stored internally. This is used automatically for any subsequent API call.

ML.authorize({
  onSuccess: function() {},
  onError: function() {},
  persist: true,
  scope: 'userinfo.email userinfo.profile mindmeister'
});

Parameters of ML.authorize(...)

ParameterDescription
onSuccessA method that is called when the authorization is granted.
onErrorA method that is called in case the authorization failed.
persistA boolean flag that indicates if the access token will be stored to window.localStorage. Default is true.
scopeThe requested scopes separated by space, e.g. 'userinfo.email mindmeister'. Default is 'userinfo.email userinfo.profile mindmeister'.

The authorization status can be check with ML.authorized(). To deauthorize the API access for the user, call ML.deauthorize().

if (ML.authorized()) {
	ML.deauthorize();
}

API Access

All Rest API endpoints can be accessed through ML.rest(...) .

Parameters of ML.rest(...)

ParameterDescription
methodOne of the HTTP methods "GET", "POST", "PUT" or "DELETE".
pathThe path of the API endpoint e.g., "/maps/1".
paramsA params object with params for the specific API endpoint. Default is {}.
onSuccessA success callback method. The API response is provided with the first parameter.
onErrorAn error callback method. The error response is provided with the first parameter.
var method = 'GET',
    path = '/maps/1',
    params = {},
    onSuccess = function(respObj) {},
    onError = function(respObj) {};

ML.rest(method, path, params, onSuccess, onError);

Additional helper methods for API access are:

  • ML.get(path, params, onSuccess, onError)

  • ML.post(path, params, onSuccess, onError)

  • ML.put(path, params, onSuccess, onError)

  • ML.delete(path, params, onSuccess, onError)

  • ML.users(id, params, onSuccess, onError)

  • ML.maps(id, params, onSuccess, onError)

  • ML.files(id, params, onSuccess, onError)

📘

/users/me

To receive user profile data from the resource owner, use the path '/users/me'. And make sure that the related scopes 'userinfo.email userinfo.profile' are provided during the authorization.