REST API Developer's Guide

Get Website Data

You can use LogicMonitor's REST API to get data for the Websites in your account.

Note: As with all of our API calls, authentication is required.

 

HTTP Method: GET

URI: /service/services/{serviceID}/checkpoints/{checkpointID}/data

Where serviceID is the service id, which can be obtained via the Services Resource. checkpointID is the id of the service checkpoint you'd like to obtain data for, which can be obtained from the checkpoints object in the service definition (make a GET request to get details for a particular service).

Request Parameters:

By default, data will be returned for the last hour. You can include the following query parameters in your request to control what data is included in the response:

Property

Description

Required?

start The start time to return data for, in epoch milliseconds No - the last hour of data will be returned by default
end The end time to return data for, in epoch milliseconds No - defaults to last hour of data
datapoints The metrics that data should be returned for No - defaults to all
format The format to return data in, where options are csv and json No - defaults to json

 

Example

The following Python script gets data from 1482865561 to 1482865719 for service 58, checkpoint 294:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='GET'
resourcePath = '/service/services/58/checkpoints/294/data'
queryParams ='?start=1482865561&end=1482865719'
data = ''

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.get(url, data=data, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content