Get Locations

Use this operation to get information about all monitoring locations available in your AlertSite account, including private locations.

Syntax

Request URL

GET https://www.alertsite.com/alertsite-restapi/locations

Authentication

This operation requires authentication.

Request Body

None.

Response Body

{
  "metadata": {
    "login": "demo@example.com",
    "message": "No errors.",
    "session": "ef770427109e343e",
    "status": "0"
  },
  "results": [
    {
      "backbone": "Cogent, Telia, Sprint",
      "browser_type": "CH,FF,IE",
      "continent": "North America",
      "country": "United States",
      "id": "20",
      "name": "Atlanta, GA",
      "region": "1"
    },
    {
      "backbone": "AT&T Wireless",
      "browser_type": "FF",
      "continent": "North America",
      "country": "United States",
      "id": "26",
      "name": "Atlanta, GA - ATT Wireless",
      "region": "3"
    },
    {
      "backbone": null,
      "browser_type": "FF",
      "continent": " InSite",
      "country": " InSite",
      "id": "10273",
      "name": " InSite: Development InSite Box - 10.0.48.7",
      "region": "0"
    },
    ... and more ...
  ]
}

Note that numeric fields (id, region) are returned as strings.

Private nodes and InSite locations have:

Code Examples

cURL

Using authentication by the session ID:

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

Using authentication via the Authorization header with a bearer token:

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

Python

This example prints a list of your AlertSite location IDs and names.

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

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.x:
token = base64.b64encode((login + ':' + session).encode('ascii')).decode('ascii')

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

See Also

© 2017 SmartBear Software. All rights reserved.      Terms of Use · Privacy Policy