How to retrieve only the first 2 data from a specific REST endpoint instead of all the data in the HTTP?
My input:
import requests
import json
url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"
response = requests.get(url)
data = response.text
parsed = json.loads(data)
print(json.dumps(parsed, indent=1))
where my output (which listed all the elements):
[
{
"sensorClass": 101,
"uID": "flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101",
"eventCode": 101,
"sensorUUID": "flgSh9oHnutzvZVOnnixFNjXIda2zula",
"timeStamp": 1.594297110372e+18,
"deviceMfg": 101,
"blobJson": "[{'deviceTimestamp': 166150, 'x': 3.8919, 'y': -8.6865, 'z': -3.3077}, {'deviceTimestamp': 166170, 'x': 4.2998, 'y': -9.8624, 'z': -2.0769}, {'deviceTimestamp': 166190, 'x': 0.74341, 'y': -9.4483, 'z': 0.57692}, {'deviceTimestamp': 166210, 'x': 0.73178, 'y': -9.5004, 'z': 3.0769}, {'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, ............................................(ALL THE DATA)
However, I want to get the out which is only contains 2 records within the blobJson string.
I want to get output as:
[
{
"sensorClass": 101,
"uID": "flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101",
"eventCode": 101,
"sensorUUID": "flgSh9oHnutzvZVOnnixFNjXIda2zula",
"timeStamp": 1.594297110372e+18,
"deviceMfg": 101,
"blobJson": "[{'deviceTimestamp': 166150, 'x': 3.8919, 'y': -8.6865, 'z': -3.3077}, {'deviceTimestamp': 166170, 'x': 4.2998, 'y': -9.8624, 'z': -2.0769}]"
}
]
which only 2 element in blobJson
What I have tried:
import requests
import json
url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"
response = requests.get(url)
data = response.text
parsed = json.loads(data)
print(json.dumps(parsed, indent=1))