Get Monitors

Last modified on August 24, 2020

The Get Monitors operation returns one, several, or all monitors. You can filter the returned monitors by type or by IDs. The response can optionally include the contents of the DéjàClick scripts, SoapUI projects and Selenium scripts used by the monitors.

Syntax

Request URL

GET https://www.alertsite.com/alertsite-restapi/devices?[id=1234,5678][&site_type=website,soapui][&show_scripts=1]

Authentication

This operation requires authentication.

Parameters

Query string parameters are optional, but can be used to filter the results:

Request Description

GET /devices

Get all monitors.

GET /devices?id=1234

Get monitor with ID 1234.

GET /devices?id=1234,5678

Get monitors 1234 and 5678.

GET /devices?site_type=dejaclick,soapui

Get all DéjàClick and SoapUI monitors.

GET /devices?site_type=soapui&show_scripts=1

Get all SoapUI monitors, including their SoapUI projects.

id

The ID of the monitor to get, or a comma-separated list of IDs. If neither id nor site_type are specified, all monitors are returned.

site_type

The monitor types to return. You can specify multiple types separated by commas, for example, site_type=dejaclick,soapui. If neither id nor site_type are specified, all monitors are returned.

Accepted values:

Value Monitor Type
dejaclick Real-browser or mobile web monitor (DéjàClick)
email-imap E-mail server (IMAP) monitor
email-pop E-mail server (POP) monitor
email-round-trip Round-trip email monitor
email-smtp E-mail server (SMTP) monitor
ftp FTP monitor
ftp-ssl FTPS (FTP over SSL) monitor
name-server DNS (Name Server) monitor
perfecto Perfecto Mobile monitor
ping Ping monitor
security-scan Security scan
selenium Selenium monitor
serveragent ServerAgent
soapui SoapUI monitor
tcp TCP monitor
transaction  
transaction-ssl  
website Web URL monitor
website-api API endpoint monitor
website-ssl Web URL monitor for https:// URLs
website-ssl-api API endpoint monitor for https:// endpoints
show_scripts

If set to 1, the response includes the contents of DéjàClick, Selenium and SoapUI files used by the monitors. This allows you to export the files to your computer.

Default value is 0, meaning the file contents is not included in the response.

DéjàClick and SoapUI

DéjàClick scripts and SoapUI projects are XML files. The response’s script field contains the text contents of the XML file, encoded as a JSON string. That is, the " \ characters and characters with codes less than 32 (new lines, tabs and others) are backslash-escaped. For example, the field value:

"script": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<con:soapui-project id=\"e0b0c87d-7b83-4689-945a-18c250254943\" ... </con:soapui-project>"

decodes to

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project id="00e97f3f-a3b4-4c6f-a61b-0c8aca654746" ...
...
</con:soapui-project>

There are JSON libraries for many programming languages that can decode JSON strings into regular strings.

Selenium

The response’s script field is the base64-encoded contents of a JAR file.

Response Body

The response contains the results array with the monitor instances that match the specified filter conditions. The data fields included in the monitor information depend on the monitor types; see Monitor Data Fields. Note that all numeric values in the response (IDs, interval and others) are strings.

{
  "metadata": {
    "login": "demo@example.com",
    "message": "No errors.",
    "session": "ef770427109e343e",
    "status": "0"
  },
  "results": [
                    
    <!-- Web monitor fields -->

    {
      "mode": "V",
      "realm_password": "",
      "realm_userid": "",
      "http_version": "1.1",
      "traceroute_on_error": "y",
      "check_ssl_expiration_dates": "Disabled",
      "timeout": "5",
      "url": "http://smartbear.com",
      "id": "123456",
      "http_method": "g",
      "enabled": "y",
      "locations": [
        {
          "id": "20",
          "name": "Atlanta, GA"
        },
        {
          "id": "10",
          "name": "Fort Lauderdale, FL"
        }
      ],
      "notify_on_content_change": "n",
      "name": "Home Page",
      "port": "",
      "interval": "1",
      "pop3_hostname": "",
      "http_302_is_error": "",
      "resolve_dns": "y",
      "notify_on_fullpage_errors": "",
      "check_fullpage_object_sizes": "",
      "http_401_is_error": "",
      "http_caching": "Disabled",
      "keyword_match_invert": "Disabled",
      "home_location": "10",
      "notify_on_error": "y",
      "fullpage_object_timeout": "10",
      "billing_plancode": "UBM - A/A",
      "interval_fullpage": "5",
      "http_follow_redirects": "y",
      "ip_address": "50.57.35.40",
      "smtp_hostname": "",
      "check_fullpage_missing_objects": "",
      "keyword_match_type": "Plain Text",
      "keyword_string": "performance",
      "monitor_location_count": "1",
      "site_type": "website"
    },

    <!-- DejaClick monitor fields -->

    {
      "billing_plancode": "UBM - A/A",
      "browser_type": "FF",
      "capture_level": "5",
      "check_fullpage_missing_objects": "",
      "check_fullpage_object_sizes": "",
      "continue_playback_on_timeout": "0",
      "enabled": "y",
      "fullpage_object_timeout": "120",
      "home_location": "10",
      "id": "1234",
      "interval": "30",
      "interval_fullpage": "30",
      "locations": [
        {
          "id": "10",
          "name": "Fort Lauderdale, FL"
        },
        {
          "id": "42",
          "name": "Los Angeles, California - Level3"
        }
      ],
      "mode": "G",
      "monitor_location_count": "0",
      "name": "Store Checkout",
      "notify_on_content_change": "n",
      "notify_on_error": "y",
      "notify_on_fullpage_errors": "",
      "site_type": "dejaclick",
      "script": "... XML file contents, encoded as a JSON string. Included only if show_scripts=1 ...",
      "step_timeout": "180",
      "timeout": "180",
      "traceroute_on_error": "y",
      "transaction_steps_allowed": "50"
    },

    <!-- SoapUI monitor fields -->

    {
      "mode": "V",
      "home_location": "10",
      "notify_on_error": "y",
      "test_case": "TestCase1",
      "billing_plancode": "UBM - A/A",
      "timeout": "300",
      "id": "12345",
      "test_suite": "TestSuite1",
      "enabled": "y",
      "capture_level": "3",
      "locations": [
        {
          "id": "10",
          "name": "Fort Lauderdale, FL"
        }
      ],
      "script": "... SoapUI XML project contents, encoded as a JSON string. Included only if show_scripts=1 ...",
      "transaction_steps_allowed": "50",
      "name": "Weather API",
      "monitor_location_count": "0",
      "interval": "60",
      "site_type": "soapui"
    }
  ]
}

Response if no monitors were found matching the specified site_type filter:

{
  "metadata": {
    "login": "demo@example.com",
    "message": "No errors.",
    "session": "ef770427109e343e",
    "status": "0"
  },
  "results": []
}

Error response:

{
  "metadata": {
    "login": "demo@example.com",
    "message": "Invalid device.",
    "session": "ef770427109e343e",
    "status": "65"
  }
}

Code Examples

cURL

In the examples below, the first command is authenticated by passing the session ID in the query string, and the second command is authenticated by using the Authorization header with a bearer token. See Authentication for details.

Get all monitors:

curl "https://www.alertsite.com/alertsite-restapi/devices?login=demo%40example.com&session=SESSION_ID"

curl -H "Authorization: Bearer BEARER_TOKEN" https://www.alertsite.com/alertsite-restapi/devices

Get monitor 1234:

curl "https://www.alertsite.com/alertsite-restapi/devices?id=1234&login=demo%40example.com&session=SESSION_ID"

curl -H "Authorization: Bearer BEARER_TOKEN" https://www.alertsite.com/alertsite-restapi/devices?id=1234

Get all DéjàClick and SoapUI monitors:

curl "https://www.alertsite.com/alertsite-restapi/devices?site_type=dejaclick,soapui&login=demo%40example.com&session=SESSION_ID"

curl -H "Authorization: Bearer BEARER_TOKEN" https://www.alertsite.com/alertsite-restapi/devices?site_type=dejaclick,soapui

Python

This example prints the IDs and names of all of your monitors.

Python

import requests # Requests library – http://docs.python-requests.org
import base64
import json

baseUrl = 'https://www.alertsite.com/alertsite-restapi'
login = 'demo@example.com' # Replace with your AlertSite login email
password = 'pa55w0rd' # Replace with your AlertSite password

# Log in
payload = {'login': login, 'password': password}
r = requests.post(baseUrl + '/login', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
session = r.json()['metadata']['session']

# Generate the bearer token to authenticate subsequent requests
# For Python 2.4-2.x:
# token = base64.b64encode(login + ':' + session)
# for Python 3.6:
token = base64.b64encode((login + ':' + session).encode('ascii')).decode('ascii')

# Get monitors
r = requests.get(baseUrl + '/devices', headers={'Authorization': 'Bearer ' + token})
result = r.json()
if result['metadata']['status'] == '0':
    for monitor in result['results']:
        print("{id}: {name}".format(**monitor))
else:
    print('Error {status}: {message}.'.format(**result['metadata']))

See Also

AlertSite JSON API
Add Monitor
Edit Monitor
Delete Monitor

Highlight search results