This is an old revision of the document!


API

NeMo exposes a simple API that enables you to programmatically get data out of NeMo (export), and put data into NeMo (import).

In order to effectively use the information in this guide, you need to have an understanding of the NeMo functionality and concepts. You should have at least a basic understanding of HTTP/JSON or a similar programming language, and basic understanding of message queuing method and software. An understanding of configuring network devices is not required, but may be helpful when actually designing an application using this API.

Architecture

The method to request or send data to NeMo is to send a JSON message containing the command and related parameters. The output will be a JSON message containing the response to the request. Users can send messages through two different channels: - via HTTP using the script api.php - via the NeMo message broker that use the AMQP protocol, through the queue “nemoapi

To test the API messages there is the page apitest.php

This is an example that send the command “hello” to the API module:

GET api.php HTTP/1.1
HOST: www.nemo.com
Content-Type: application/json

{"token":"1234567890ABCD", "cmd": "hello", "param":{}}

If everything works fine, the response will be in the form:

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14
Content-Type: application/json
Connection: Closed
{"success":true,"request":{"cmd":"hello", "param":{}}, "response":{"answer":"hello"}}

The format of the response JSON is in the form:

{
   "success": true,   //or false
   "error": "ERROR_CODE", // an error code 
   "message": "a textual message explaining the error", //used only if success=false
   "request": {},  //the JSON received in the request
   "response": {}   //an object containing the response data
}

Authetication

NeMo API use JSON Web Token (JWT) as authentication method. The first thing to do is to access the system with a username and password, and then receive a token to use in subsequent requests. The token is valid for 5 minutes from the moment it is issued.

{
   "cmd": "login",
   "param": {
       "username": "myuser",
       "password": "mypasswd"
   }
}

This is a simple response:

{
   "success":true,
   "request": {
      "cmd":"login",
      "param": { 
          "username":"myuser",
          "password":"mypasswd"
      }
    },
    "response":{
      "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjAiLCJpYXQiOjE0ODUxODE5MDN9.TO4t8OUrRIDxa6mmaEGI8cNkwv5F9vkSdfH_XVNbz5g"
   }
}

Alarms

These are the command to use in order to obtain information about alarms.

alarmActive

Get all active alarms.

Request:

{
   "cmd": "alarmActive",
   "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
   "param": {  }
}

Response:

{
   "success": true,
   "request": 
    {
       "cmd": "alarmActive",
       "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
       "param": {  }
    },
    "response": [
    {....},
    {....}
    ]

The “response” field contains an array of event description. The format is the same as that contained in te alarmGet command.

alarmGet

Request information about a single alarm.

Request:

{
   "cmd": "alarmGet",
   "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
   "param": {
      "eventId": 123
   }
}

Response:

{
   "success": true,
   "request": 
   {
       "cmd": "alarmGet",
       "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...."
       "param": {
          "eventId": 123
       }
    },
    "response":
    {
        eventId: 12345,
        type: 1,
        typeString: “Threshold”,
        deviceId: 1234,
        deviceName: “NODE0101”,
        entityId: 12345,
        thresholdId: 12345,
        description: “DOWN Interface Gi0/1/1.2”
        status: 10,
        statusString: “Active”,
        level: 5,
        levelString: “Critical”,
        start: 1472577290,
        restart: 1472577290,
        end: 0,
        elementInfo: {
	        ifIndex: 23,
	        ifDescr: “GigabitEthernet0/1/1.2”,
	        ifName: “Gi0/1/1.2”,
	        ifType: “Ethernet”,
	        ifAlias: “”,
	        ....
        }
    }
}