How to automate queries to the web interface (RestAPI) Python3?

Good day, colleagues,

There is a need to upload a JSON file with data for a certain period of time from the web interface via RestAPI. Limit records in the received file - 100. In the file information about the actions and the time when the action happened. If the requested time span of the data more than 100 records, the response received, this is signaled by - moreDataAvailable = True. To obtain the missing data necessary to generate a new request and the url to register the time of the last received event (starttime) and add to it 1 millisecond.

In Python e failed to make the request to the Web interface via requests.get()
>>> import requests
>>> response = requests.get(
... 'https://api.blablabla.com/event/eventstatuses?requestId=1234&datetype=received&starttime=2020-02-10T00%3A00%3A57.001Z&...'
... )
>>> json_response = response.json()
>>> print(json_response)


How is it possible to automate requests to upload all the necessary data for the requested period? (moreDataAvailable = False) whether obtained JSON—č be combined into one?
April 7th 20 at 15:41
1 answer
April 7th 20 at 15:43
Loop request subject to the availability of data
DataAvailable = True
while DataAvailable:
 ... 
 DataAvailable = json_responce["MoreDataAvailable"] 
 start_time = new_start_time
Alexander thought about it, but in this case I have the starttime is in the URL. Accordingly, with each new request this parameter in the URL needs to change. Therefore, the question arises how to make it there to change... - Samara64 commented on April 7th 20 at 15:46
First to use datetime and strftime to date is stored as date and format as the string in the URL (have to read the documentation), and allow the settings to a convenient form, as in @v2.5.3
Probably still have to parse the date from the timing for this is strptime - Jayne.Flatley82 commented on April 7th 20 at 15:49

Find more questions by tags JSONPythonRESTful API