Retrieve and Search Last Values

Sometimes instead of querying entire events, you just need the last value of some tags. If you just need the last value, the query can be faster since it is looked up from a specific cached last value table instead of from the events stream.

 

Similarly, it can be useful to search the last values to see which users or devices contain a specific value. 

 

Get last value for user

Get last value for tags associated with the specified user. The POST method is used when querying a large list of tags.

Summary

  • Endpoint:/v2/analytics/last_value/<login_id>
  • Method: GET/POST
  • Permissions: This operation is permitted for Basic User and Business User roles. A user with the Basic User role can only see its own data. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

GET: Path

  • field: tag to get last value for, written with its stream, ie "raw.device_id", where "raw" is the stream and "device_id" is the tag
    • This field can be used more than once to query more than one tag - see the examples for more info 
    • If no field is provided, all last values for the user will be returned

POST: Body

  • fields: list of tags to get last value for, written with its stream, ie "raw.device_id", where "raw" is the stream and "device_id" is the tag

 

HTTP Response

200 OK

  • Data successfully queried. Returns a list of dictionaries of the format {<tag>:<last value>, observed_at: <time of event with last value>}

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Query specific tags

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data (GET version)
curl -b cookies.txt -X GET -k -H 'Content-Type: application/json' -i https://api.mediumone.com/v2/analytics/last_value/device03?field=raw.temperature&field=processed.device_id

# send data (POST version)
curl -b cookies.txt -X POST -k -H 'Content-Type: application/json' -i "https://api.mediumone.com/v2/analytics/last_value/device03" -d '{"fields":["raw.temperature", "processed.device_id"]}'

# response: [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"raw.temperature": 80, "observed_at": "2021-02-03T02:28:13.917722+00:00"}]

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

# GET version
get_url = 'https://api.mediumone.com/v2/analytics/last_value/device03?field=raw.temperature&field=processed.device_id'

response = session.get(url=get_url, headers=headers) # [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"raw.temperature": 80, "observed_at": "2021-02-03T02:28:13.917722+00:00"}]

# POST version
post_url = 'https://api.mediumone.com/v2/analytics/last_value/device03'
body = {"fields":["raw.temperature", "processed.device_id"]}

response = session.post(url=url, data=json.dumps(body), headers=headers) # [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"raw.temperature": 80, "observed_at": "2021-02-03T02:28:13.917722+00:00"}]

Query all tags

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -X GET -k -H 'Content-Type: application/json' -i https://api.mediumone.com/v2/analytics/last_value/device03

# response: [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"observed_at": "2020-09-12T04:49:11.759747+00:00", "up.tenant_api_basic_users": ["t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7"]}, {"observed_at": "2020-09-25T16:48:33.264477+00:00", "commands_to_device.ts": "1601052513"}, {"observed_at": "2020-09-25T16:48:33.264477+00:00", "commands_to_device.cmd": "e"}, {"commands_to_device.data": "2", "observed_at": "2020-09-25T16:48:33.264477+00:00"}]

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

url = 'https://api.mediumone.com/v2/analytics/last_value/device03

response = session.get(url=url, headers=headers)
# response:
#  [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"observed_at": "2020-09-12T04:49:11.759747+00:00", "up.tenant_api_basic_users": ["t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7"]}, {"observed_at": "2020-09-25T16:48:33.264477+00:00", "commands_to_device.ts": "1601052513"}, {"observed_at": "2020-09-25T16:48:33.264477+00:00", "commands_to_device.cmd": "e"}, {"commands_to_device.data": "2", "observed_at": "2020-09-25T16:48:33.264477+00:00"}]

 

Get last N values for specific tags

Get last value for specified tags associated with the specified user.

Summary

  • Endpoint:/v2/analytics/last_n_values/<login_id>
  • Method: GET
  • Permissions: This operation is permitted for Basic User and Business User roles. A user with the Basic User role can only see its own data. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Path

  • field: tag to get last value for, written with its stream, ie "raw.device_id", where "raw" is the stream and "device_id" is the tag
    • Required 
    • This field can be used more than once to query more than one tag - see the examples for more info 
  • limit: tag to get last value for, written with its stream, ie "raw.device_id", where "raw" is the stream and "device_id" is the tag
    • Default: 1
    • Max: 10

HTTP Response

200 OK

  • Data successfully queried. Returns a list of dictionaries of the format {<tag>:<last value>, observed_at: <time of event with last value>}

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Query specific tags

Curl

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -X GET -k -H 'Content-Type: application/json' -i https://api.mediumone.com/v2/analytics/last_n_values/device03?field=processed.device_id&limit=2

# response: [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"processed.device_id": "device2", "observed_at": "2020-03-26T17:01:49.067000+00:00"}]

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'biz_user', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

url = 'https://api.mediumone.com/v2/analytics/last_n_values/device03?field=processed.device_id&limit=2'

response = session.get(url=url, headers=headers)
# response: [{"processed.device_id": "device", "observed_at": "2020-03-26T19:01:49.067000+00:00"}, {"processed.device_id": "device2", "observed_at": "2020-03-26T17:01:49.067000+00:00"}]

 

Search tags for specified users

This is like a last value search, but with added constraints and search abilities.

 

Note: ALL values are returned as strings, so if you are working with numbers, lists, or objects, you will have to convert them for use.

Summary

  • Endpoint:/v2/analytics/last_value_query_with_constraint
  • Method: POST
  • Permissions: This operation is permitted for Basic User and Business User roles. A user with the Basic User role can only see its own data. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Path

  • users- list of basic users to search
    • Default: all devices linked to tenant
    • Type: list of strings
  • search_fields- list of tags to search
    • Default: all tags
    • Type: list of strings
    • Required with use of search_values
  • search_values - list of values to search for in each tag
    • Default: empty string (will match all values)
    • Type: list of strings
    • Required with use of search_fields
    • The search looks for values that contain any of the search_values (case insensitive) - it does NOT have to be an exact match
  • output_fields - list of tags to return in response
    • Default: all tags
    • Type: list of strings
  • constraint_field - tag that you want to check has a certain value
    • Default: None
    • Type: string
    • Required with use of constraint_value
  • constraint_value - if a user has the tag constraint_field and its value is equal to constraint_value, the device will be included in the search, otherwise it will not be included
    • Default: None
    • Type: string
      • Even if you are constraining with a non-string tag this value should be a string. For example, for a boolean tag, you would set constraint_value to "true" or "false".
    • Required with use of constraint_field

HTTP Response

200 OK

  • Data successfully queried. 
  • Returns an array of arrays. The first array, ["user", "tags", "last_values"], defines what each index of the following arrays contain. See the example for more info. 

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Query last values for two devices

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint" -d '{"users":["device03","device02"]}'

# response [["user", "tags", "last_values"], ["device02", ["up.device_type_id_list", "up.tenant_api_basic_users", "raw.active"], ["[]", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]"], "true"]], ["device03", ["processed.device_id", "commands_to_device.data", "up.tenant_api_basic_users", "commands_to_device.cmd", "commands_to_device.ts", "raw.active"], ["device", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "e", "1601052513", "true"]]]

 

Search by device ID tag existence

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint" -d '{"search_fields":["processed.device_id"],"search_values":[""]}'

# response [["user", "tags", "last_values"], ["device03", ["processed.device_id", "commands_to_device.ts", "commands_to_device.cmd", "commands_to_device.data", "up.tenant_api_basic_users", "raw.active"], ["device", "1601052513", "e", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "true"]]]

 

Only output device ID tag

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint" -d '{"output_fields":["processed.device_id"]}'

# response [["user", "tags", "last_values"], ["device03", ["processed.device_id"], ["device"]]]

 

Constrain by active tag

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint" -d '{"users":["device03","device02"], "constraint_field": "raw.active", "constraint_value": "true"}'

# response [["user", "tags", "last_values"], ["device02", ["up.device_type_id_list", "up.tenant_api_basic_users", "raw.active"], ["[]", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]"], "true"], ["device03", ["processed.device_id", "commands_to_device.data", "up.tenant_api_basic_users", "commands_to_device.cmd", "commands_to_device.ts", "raw.active"], ["device", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "e", "1601052513", "true"]]]

 

Search tags for specified users with timestamp

This is the same as the above endpoint, but the timestamp of the values is included in the response.

 

Note: ALL values are returned as strings, so if you are working with numbers, lists, or objects, you will have to convert them for use.

Summary

  • Endpoint:/v2/analytics/last_value_query_with_constraint_with_timestamps
  • Method: POST
  • Permissions: This operation is permitted for Basic User and Business User roles. A user with the Basic User role can only see its own data. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Path

  • users- list of basic users to search
    • Default: all devices linked to tenant
    • Type: list of strings
  • search_fields- list of tags to search
    • Default: all tags
    • Type: list of strings
    • Required with use of search_values
  • search_values - list of values to search for in each tag
    • Default: empty string (will match all values)
    • Type: list of strings
    • Required with use of search_fields
    • The search looks for values that contain any of the search_values (case insensitive) - it does NOT have to be an exact match
  • output_fields - list of tags to return in response
    • Default: all tags
    • Type: list of strings
  • constraint_field - tag that you want to check has a certain value
    • Default: None
    • Type: string
    • Required with use of constraint_value
  • constraint_value - if a user has the tag constraint_field and its value is equal to constraint_value, the device will be included in the search, otherwise it will not be included
    • Default: None
    • Type: string
      • Even if you are constraining with a non-string tag this value should be a string. For example, for a boolean tag, you would set constraint_value to "true" or "false".
    • Required with use of constraint_field

HTTP Response

200 OK

  • Data successfully queried. 
  • Returns an array of arrays. The first array, ["user", "tags", "last_values", "event_obs"], defines what each index of the following arrays contain. See the example for more info. 

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

Query last values for two devices

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_timestamps" -d '{"users":["device03","device02"]}'

# response [["user", "tags", "last_values", "event_obs"], ["device02", ["up.device_type_id_list", "up.tenant_api_basic_users", "raw.active"], ["[]", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]"], "true"], [ "2020-09-25T16:48:33.264477+00:00", "2020-09-12T04:49:11.759747+00:00", "2020-09-12T04:49:11.759747+00:00"]], ["device03", ["processed.device_id", "commands_to_device.data", "up.tenant_api_basic_users", "commands_to_device.cmd", "commands_to_device.ts", "raw.active"], ["device", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "e", "1601052513", "true"], ["2020-03-26T19:01:49.067000+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-12T04:49:11.759747+00:00", "2020-09-12T04:49:11.759747+00:00"]]]

 

Search by device ID tag existence

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_timestamps" -d '{"search_fields":["processed.device_id"],"search_values":[""]}'

# response [["user", "tags", "last_values", "event_obs"], ["device03", ["processed.device_id", "commands_to_device.data", "up.tenant_api_basic_users", "commands_to_device.cmd", "commands_to_device.ts", "raw.active"], ["device", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "e", "1601052513", "true"], ["2020-03-26T19:01:49.067000+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-12T04:49:11.759747+00:00", "2020-09-12T04:49:11.759747+00:00"]]]

 

Only output device ID tag

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_timestamps" -d '{"output_fields":["processed.device_id"]}'

# response [["user", "tags", "last_values", "event_obs"], ["device03", ["processed.device_id"], ["device"], ["2020-03-26T19:01:49.067000+00:00"]]]

 

Constrain by active tag

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_timestamps" -d '{"users":["device03","device02"], "constraint_field": "raw.active", "constraint_value": "true"}'

# response [["user", "tags", "last_values", "event_obs"], ["device02", ["up.device_type_id_list", "up.tenant_api_basic_users", "raw.active"], ["[]", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]"], "true"], [ "2020-09-25T16:48:33.264477+00:00", "2020-09-12T04:49:11.759747+00:00", "2020-09-12T04:49:11.759747+00:00"]], ["device03", ["processed.device_id", "commands_to_device.data", "up.tenant_api_basic_users", "commands_to_device.cmd", "commands_to_device.ts", "raw.active"], ["device", "2", "[\"t_c0f9e8fb-5171-4ace-9fd7-c36d7c879ba7\"]", "e", "1601052513", "true"], ["2020-03-26T19:01:49.067000+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-25T16:48:33.264477+00:00", "2020-09-12T04:49:11.759747+00:00", "2020-09-12T04:49:11.759747+00:00"]]]

 

Search tags for specified users with pagination

This is like the "Search tags for specified users" endpoint, but the results are paginated. The response does not include timestamps.

 

Note: ALL values are returned as strings, so if you are working with numbers, lists, or objects, you will have to convert them for use.

Summary

  • Endpoint:/v2/analytics/last_value_query_with_constraint_with_pagination
  • Method: POST
  • Permissions: This operation is permitted for Basic User and Business User roles. A user with the Basic User role can only see its own data. 

Headers

Content-Type: application/json
Accept: application/json
Cookies: < login cookies >

Path

  • users- list of basic users to search
    • Default: all devices linked to tenant
    • Type: list of strings
  • search_fields- list of tags to search
    • Default: all tags
    • Type: list of strings
    • Required with use of search_values
  • search_values - list of values to search for in each tag
    • Default: empty string (will match all values)
    • Type: list of strings
    • Required with use of search_fields
    • The search looks for values that contain any of the search_values (case insensitive) - it does NOT have to be an exact match
  • output_fields - list of tags to return in response
    • Default: all tags
    • Type: list of strings
  • constraint_field - tag that you want to check has a certain value
    • Default: None
    • Type: string
    • Required with use of constraint_value
  • constraint_value - if a user has the tag constraint_field and its value is equal to constraint_value, the device will be included in the search, otherwise it will not be included
    • Default: None
    • Type: string
      • Even if you are constraining with a non-string tag this value should be a string. For example, for a boolean tag, you would set constraint_value to "true" or "false".
    • Required with use of constraint_field
  • limit - number of results to return if using pagination
    • Default: None
    • Type: integer
    • Required with use of start_pagination_id
  • start_pagination_id - pagination will start after this ID
    • Default: None
    • Type: string
    • Required with use of limit
      • When getting first page, set start_pagination_id to "0"

HTTP Response

200 OK

  • Data successfully queried. 
  • Returns an array of arrays. The first array, ["user", "tags", "last_values"], defines what each index of the following arrays contain. See the example for more info. 

400 BAD REQUEST

  • The request was missing parameters or the parameters were not formatted correctly.

401 UNAUTHORIZED

  • No authorized user is currently logged in.

403 FORBIDDEN

  • No user matching login_id can be found or not authorized to post data for the given user.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the request. Please try again.

Examples

First page request

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_pagination" -d '{"limit":1,"start_pagination_id":"0", "output_tags": ["raw.device_id", "device_data.status"], "search_values": ["bot"], "search_tags": ["raw.device_id"]}'

# response [["user", "tags", "last_values"],["bot_1", ["raw.device_id", "device_data.status"], ["bot_1", "active"], "12345"]]

 

Second page request

# login as API Basic User and save session cookies
curl -c cookies.txt -i -X POST -d '{"login_id":"biz_user","password":"12345","api_key":"ABCDEFGHIJKLMNOPabcdefghijklmnop1234567890"}' https://api.mediumone.com/v2/login/ --header "Content-Type: application/json"

# send data
curl -b cookies.txt -k -i -X POST -H "Accept: application/json" "https://api.mediumone.com/v2/analytics/last_value_query_with_constraint_with_pagination" -d '{"limit":1,"start_pagination_id":"12345", "output_tags": ["raw.device_id", "device_data.status"], "search_values": ["bot"], "search_tags": ["raw.device_id"]}'

# response [["user", "tags", "last_values"],["bot_2", ["raw.device_id"], ["bot_2"], "11122"]]