Author Topic: Getting Total Trunks with Genesys API  (Read 178 times)

Offline victor

  • Administrator
  • Hero Member
  • *****
  • Posts: 1416
  • Karma: 18
Getting Total Trunks with Genesys API
« on: August 28, 2024, 03:35:14 AM »
Is there a simple way to get the count of active trunks using API?

I would imagine something like this:


```
import requests

url = "https://api.mypurecloud.com/api/v2/telephony/providers/edges/trunks"
headers = {
    "Authorization": "Bearer MY_SUPER_SECRET_TOKEN",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
trunks = response.json().get("entities", [])

# Count the number of trunks that are connected
active_trunks = sum(1 for trunk in trunks if trunk.get("connectedStatus") == "connected")

print(f"Total number of active trunks: {active_trunks}")
```

But for the life of me, this does not give me what I want. Where am I going wrong? (Other than the use of "sum" and "for" together - don't kill me :) )


Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Getting Total Trunks with Genesys API
« Reply #1 on: August 28, 2024, 02:56:00 PM »
As far as I know there is no other way how to get number of active (connected) trunks