Track traffic by script

There's some way to check if some api on Apigee is getting traffic or not via script? 
We are running job script on ControlCentre to delete Apis on Publish/Products automated but before run the job we wanna check if has traffic 

0 4 125
4 REPLIES 4

I can think of this beautiful development by @dchiesa1 

https://github.com/DinoChiesa/ApigeeEdge-API-Traffic-Summarizer

Yes, you could use that, ... that one might be overkill, because it analyzes all proxies in the organization. If you want to check just one proxy, you'd need to use a simpler, single call.

Something like this would do it.

 

GET https://api.enterprise.apigee.com/v1/organizations/MYORG/environments/MYENVIRONMENT/stats/apis?select=sum(message_count)&timeUnit=month&timeRange=01/01/2021 08:00~12/31/2021 08:00

 

Just parse the JSON response and look for your desired proxy.

You can also add a filter queryparam, to retrieve data only for a specific proxy, or a set of proxies. Check the documentation for more details.

 

another option that you could use is the debug session. If your purpose is to deploy an api, as part of a ci/cd pipeline, in which you deploy, invoke some calls, verify results, then Undeploy, then the debugsession may be the right tool for you.  It will collect data more quickly than the /stats api, you won’t have to wait for aggregation intervals. 

To better understand the context of the question, do you mean you want to check if the API is in the middle of processing a request? 

Also, why are you deleting the API? Are you doing this as part of an API upgrade or just to delete it? If it's the latter, would deleting even matter then? If it's an upgrade, there's no need to delete the existing API