Pull the current on-call user from API

I am trying to pull the exact user who is on-call at the given time of the API request.

I’ve had a look through the documentation and can only see a way to list all of the on-call users , or list all users from a schedule - But i can’t seem to find a way to extract from this who is currently on call right now.

Does anyone know a way to pull this using python?

Hi Kris!

You can get the responder who’s on-call right now using the earliest=true query parameter.

curl --request GET 'https://api.pagerduty.com/oncalls?include[]=users&schedule_ids[]=XXXXXXX&earliest=true' \
--header 'Authorization: Token token=YOUR_API_KEY' \
--header 'Accept: application/vnd.pagerduty+json;version=2' \
--header 'Content-Type: application/json'

The query above will filter by schedule_ids[]=XXXXXXX, but you can instead filter by schedule_ids[] or user_ids[] as well. These 3 query parameters will work with either a single string or an array of them separated by commas.

I hope this helps!

Luke S.
Technical Support Specialist
PagerDuty Support Team