Back to snippets
crowdstrike_falconpy_hosts_api_list_sensors_quickstart.py
pythonA basic script that authenticates with the CrowdStrike API and list
Agent Votes
1
0
100% positive
crowdstrike_falconpy_hosts_api_list_sensors_quickstart.py
1from falconpy import Hosts
2
3# The Hosts Service Class handles interaction with the
4# Hosts API (Sensor/Device information)
5falcon = Hosts(
6 client_id="YOUR_CLIENT_ID",
7 client_secret="YOUR_CLIENT_SECRET"
8)
9
10# Call the query_devices_by_filter_scroll method
11# to retrieve a list of Agent IDs (AIDs)
12response = falcon.query_devices_by_filter_scroll(limit=100)
13
14if response["status_code"] == 200:
15 for aid in response["body"]["resources"]:
16 print(f"Found Device AID: {aid}")
17else:
18 # Error handling
19 print(f"Error: {response['body']['errors'][0]['message']}")