Ask the Community
Groups
Tip: How to access the Traverse REST API - Connect IT Community | Kaseya
<main> <article class="userContent"> <p><strong>QUESTION</strong></p> <p>How to access the Traverse REST API?</p> <p><strong>RESOLUTION</strong></p> <p>The REST API allows access to many of Traverse's features and is documented in the Traverse Developer Guide.</p> <p>In order to establish a session with the REST API, a login request must be sent with valid Traverse username and password using a REST client or Web Browser:</p> <p><a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2F10.10.10.10%2Fapi%2Frest%2Fcommand%2Flogin%3Fsuperuser%2Ftraverse">https://10.10.10.10/api/rest/command/login?superuser/traverse</a></p> <pre class="code codeBlock" spellcheck="false" tabindex="0">OK 201 request accepted and processed, ready for next request</pre> <p>The response from the REST API will contain authentication credentials in the form of a cookie with the key 'TraverseJSessionID'. This cookie may then be included in the header of subsequent requests.</p> <p>Note that most Web Browsers will automatically cache the cookie provided in the 'login' response, and include it in subsequent requests. When using a REST client it may be necessary to explicitly capture the cookie and use it in subsequent requests.</p> <p>Once an authenticated session has been established, we may then issue any of the REST API commands (which are similar to BVE API commands), such as:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0"><a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2F10.10.10.10%2Fapi%2Frest%2Fcommand%2Ftest.list%3FdeviceName%3DTraverse">https://10.10.10.10/api/rest/command/test.list?deviceName=Traverse</a> Server&testType=jmx&subType=nv_msgsvr_event_reject</pre> <p>With a response of:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">OK 203 request accepted, records returned: 3 "serialNumber=90040", "testName=Number Of Messages Discarded (By Rule)", "testType=jmx", "subType=nv_msgsvr_event_reject", "deviceName=Traverse Server", "accountName=Core Infrastructure", "jmxremotePort=7693", "protocol=IIOP", "remoteApplicationDomainName=", "loginName=", "interval=300", "warningThreshold=5000", "criticalThreshold=20000", "shadowWarningThreshold=5000", "shadowCriticalThreshold=20000", "slaThreshold=5000", "units=msgs/min", "actionName=None", "scheduleName=Default Schedule", "flapPreventionWaitCycles=0", "thresholdType=1", "suppressed=false", "isSuspended=false", "timeBasedThresholds=false", "resultProcessDirective=3", "resultMultiplier=60.0", "maxValue=100000","jmxProperty=NetVigil:type=MessageServer|MessagesDiscardedByRule" "serialNumber=90029", "testName=Number Of Messages Discarded (No Match)", "testType=jmx", "subType=nv_msgsvr_event_reject", "deviceName=Traverse Server", "accountName=Core Infrastructure", "jmxremotePort=7693", "protocol=IIOP", "remoteApplicationDomainName=", "loginName=", "interval=300", "warningThreshold=5000", "criticalThreshold=20000", "shadowWarningThreshold=5000", "shadowCriticalThreshold=20000", "slaThreshold=5000", "units=msgs/min", "actionName=None", "scheduleName=Default Schedule", "flapPreventionWaitCycles=0", "thresholdType=1", "suppressed=false", "isSuspended=false", "timeBasedThresholds=false", "resultProcessDirective=3", "resultMultiplier=60.0", "maxValue=100000","jmxProperty=NetVigil:type=MessageServer|MessagesDiscardedNoMatchingRule" "serialNumber=90020", "testName=Number Of Messages Discarded (Unknown Device)", "testType=jmx", "subType=nv_msgsvr_event_reject", "deviceName=Traverse Server", "accountName=Core Infrastructure", "jmxremotePort=7693", "protocol=IIOP", "remoteApplicationDomainName=", "loginName=", "interval=300", "warningThreshold=5000", "criticalThreshold=20000", "shadowWarningThreshold=5000", "shadowCriticalThreshold=20000", "slaThreshold=5000", "units=msgs/min", "actionName=None", "scheduleName=Default Schedule", "flapPreventionWaitCycles=0", "thresholdType=1", "suppressed=false", "isSuspended=false", "timeBasedThresholds=false", "resultProcessDirective=3", "resultMultiplier=60.0", "maxValue=100000","jmxProperty=NetVigil:type=MessageServer|MessagesDiscardedNoMatchingDevice"</pre> <p> </p> <p>Output may also be presented in JSON format by including the 'format=json' parameter in the request:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0"><a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2F10.10.10.10%2Fapi%2Frest%2Fcommand%2Fdevice.list%3FdeviceName%3DTraverse">https://10.10.10.10/api/rest/command/device.list?deviceName=Traverse</a> Server&format=json </pre> <p> with a response of:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">{"api-response":{"data":{"object":[{"serialNumber":"80018","deviceName":"Traverse Server","address":"127.0.0.1","deviceType":"Linux/Other Unix","parentNames":"","tag1 (Tag 1)":"","tag2 (Tag 2)":"","tag3 (Tag 3)":"","tag4 (Tag 4)":"","tag5 (Tag 5)":"","locationName":"Corporate","dgeName":"dge-1","isSuspended":"false","clearOnOk":"false","smartNotify":"true","showOnSummary":"true","accountSerialNumber":"49","accountName":"Core Infrastructure","isReadOnly":"false","model":"2.6.32-573.7.1.el6.x86_64","vendor":"Linux","rediscoveryEnabled":"false","configBackupEnabled":"false","processCollectionEnabled":"true","flapPreventionWaitCycles":"-1","comment":"Performance of Kaseya Traverse running on the local server"}]},"status":{"code":"203","error":"false","message":"request accepted, records returned: 1"}}} </pre> <p> Using a utility such as '<a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fjsonviewer.stack.hu%2F" rel="noreferrer nofollow">http://jsonviewer.stack.hu/</a>' to format the output shows:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">{ "api-response": { "data": { "object": [ { "serialNumber": "80018", "deviceName": "Traverse Server", "address": "127.0.0.1", "deviceType": "Linux/Other Unix", "parentNames": "", "tag1 (Tag 1)": "", "tag2 (Tag 2)": "", "tag3 (Tag 3)": "", "tag4 (Tag 4)": "", "tag5 (Tag 5)": "", "locationName": "Corporate", "dgeName": "dge-1", "isSuspended": "false", "clearOnOk": "false", "smartNotify": "true", "showOnSummary": "true", "accountSerialNumber": "49", "accountName": "Core Infrastructure", "isReadOnly": "false", "model": "2.6.32-573.7.1.el6.x86_64", "vendor": "Linux", "rediscoveryEnabled": "false", "configBackupEnabled": "false", "processCollectionEnabled": "true", "flapPreventionWaitCycles": "-1", "comment": "Performance of Kaseya Traverse running on the local server" } ] }, "status": { "code": "203", "error": "false", "message": "request accepted, records returned: 1" } } } </pre> <p> </p> <p>Here is an example using 'curl' to send a request using the authenticated session cookie provided by the 'login' service:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0">curl -k -X GET <a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2F10.10.10.10%2Fapi%2Frest%2Fcommand%2Fdevice.list">https://10.10.10.10/api/rest/command/device.list</a> \<br> -H 'Cache-Control: no-cache' \<br> -H 'accept: */*' \<br> -H 'cookie: TraverseJSessionID=67F2BC7A6717F21379F618A07CBCAF9A'</pre> <p>Lastly, the 'logout' command may be used to terminate the session:</p> <pre class="code codeBlock" spellcheck="false" tabindex="0"><a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2F10.10.10.10%2Fapi%2Frest%2Fcommand%2Flogout%3Fsuperuser%2Ftraverse">https://10.10.10.10/api/rest/command/logout?superuser/traverse</a></pre> <p><strong>Note:</strong> We strongly recommend 'HTTPS' (SSL) to encrypt the communication with the Traverse REST API. With HTTP all information is sent in clear text including the username, password and basic authentication credentials.</p> <p>Please review the Traverse Developer Guide for additional details on the various Traverse APIs.</p> <p><strong>REFERENCE </strong></p> <p><a rel="nofollow" href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fhelp.kaseya.com%2FwebHelp%2FEN%2FTV%2F9050000%2FDEV%2Findex.asp%23home.htm">Traverse Developer Guide</a></p> <p><a rel="nofollow" href="/home/leaving?allowTrusted=1&target=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FBasic_access_authentication">HTTP Basic Access Authentication</a></p> <p><a rel="nofollow" href="/home/leaving?allowTrusted=1&target=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FList_of_HTTP_header_fields">HTTP Header Fields</a></p> </article> </main>