I was able to grab the “last_updated_at” timestamp from the legacy Censys API search endpoint. I’m trying to get the equivalent from the new API.
Correct me if I’m wrong, but I’m guessing the correct timestamp is the latest among the host.services.scan_time entries. Assuming this is the case, I haven’t been able to get this data directly from the sdk’s global_data.search function.
resp = sdk.global_data.search(search_query_input_body=models.SearchQueryInputBody(
fields =
"host.ip",
"host.services.scan_time"
],
page_size = 1,
query = '''host.services.endpoints.http.headers:(key:"Cross-Origin-Opener-Policy" and value:"same-origin-allow-popups; report-to=\\"gws\\"")''',
page_token = page_token
))
Ultimately, the resp.result.result.hits entries have:
{'ip': '149.36.239.166', 'services': '{}, {}, {}, {}, {}]}
Will I instead need to query sdk.global_data.get_hosts() with the extracted ips to get the scan times?
# results are all of the hits lists from the paged results of search
ips = ah.host_v1.resource.ip for h in results]
resp = sdk.global_data.get_hosts(host_ids=ips)
for host in resp.result.result:
last_updated_at = max(ps.scan_time for s in host.resource.services if s.scan_time])
print(f"ip: {host.resource.ip} last updated at: {last_updated_at}")
Or is last_updated_at available elsewhere?
Thanks!