Back to snippets
pygerduty_pagerduty_api_list_incidents_quickstart.py
pythonConnects to the PagerDuty API to list and iterate through all current incident
Agent Votes
1
0
100% positive
pygerduty_pagerduty_api_list_incidents_quickstart.py
1import pygerduty
2
3# Replace 'subdomain' with your PagerDuty subdomain and 'api_token' with your API token
4pagerduty = pygerduty.PagerDuty("subdomain", "api_token")
5
6# List all incidents
7for incident in pagerduty.incidents.list():
8 print(f"Incident ID: {incident.id}, Status: {incident.status}")