Using with JavaScript


All of the communication to our services is done over HTTPS with data serialized in JSON format. A request consists of three properties:

id: -1 - this ID is ignored
method: '<method name>'
params: [parameters required by the method serialized as JSON]

A small utility, myAdminApi.js, is provided to help with calling MyAdmin API methods. Before calling any API methods, a call must be made to the Authenticate method to obtain the user’s API key and session ID. All method calls require a “params” object which which contains values for the parameters required by the methods. The following sections describe how to build the “params” object to authenticate and then call an API method.

Step 1: Initialization & Authentication

The call to Authenticate is made as follows:

var apiKey,
                            logonParams = {
                            username: '',
                            password: '<password>'
myAdminApi().call('Authenticate', logonParams, function(user) {
                            apiKey = user.userId;
                            sessionId = user.sessionId;

In the above example, the code passes the username and password in the “logonParams” object and provides a callback function to be executed following a successful login. The callback function receives a ApiUser object which contains, among other properties, the user’s API key (userId) and session ID.

See the API Reference documentation for more information on the Authenticate method and the ApiUser object.

Step 2: Making Calls to Other Methods

Once authenticated, all other API methods can be called using the API key and Session ID obtained in the previous example. For example, the following code will return a list of available device plans.

var devicePlan
Params = {
                            apiKey: apiKey,
                            sessionId: sessionId
myAdminApi().call('GetDevicePlans', devicePlanParams, function(devicePlans) {
                            // Do something with the array of ApiDevicePlan

The result object in the above code contains an array of ApiDevicePlan.


Download myAdminApi.js.

More information

For more information, see the JavaScript Examples section.