Back to snippets

pygerduty_pagerduty_api_list_incidents_quickstart.py

python

Connects to the PagerDuty API to list and iterate through all current incident

15d ago8 linesdropbox/pygerduty
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}")