I need to make repeated api calls as there is a limit on each call of 1000 records. There are about 20,000 total records of which I test them , keep a sample, then need request the next 1000. The offset parameter is available.
p = getpass.getpass()
url = ("https://example.api.com/api/1.0/devices/all/?offset={}&include_cols=asset_no,name,service_level,building&type=physical"
r = requests.get(url, auth=HTTPBasicAuth('admin', p))
data = json.loads(r.text)
payload = data["Devices"]
offset value should increment by 1000 each api call, (ex. offset = 1000, offset = 2000, offset = 3000, etc) until all pages retrieved.
How could I create a function that makes paginated api calls using this offset parameter? I believe a generator is what is needed, but I'm unable to understand the examples I've found, with the offset parameter I need to use.