How to use REST API to get count of running process instances

I have a single process definition that I would like to know the number of current running process instances, completed process instances, canceled, etc. Something I could use to know how many executed and how many are are still running.

I have used postman and GET /history/process-definition/{Process_id}/statistics with query parameters but that gives me all the activities within the process and not the information for the entire process.

I am using the REST API because I am calling the API from Python so I am really focused on the REST API

Second it seems like I have to use different query parameters to get the number of instances and the number of finished. I could calculate the number of still executing as the difference but this seems harder than it should be and I think I must be missing something

Questions

  1. Is there a REST API call that simply gives me for a process definition, the number of still running process instances and/or completed instances for that definition at a summary level and not at the activity level
  2. Or is there an easy way to chain the query parameters together to give me the finished and instance count in the same API call or do I have to use two calls…

Thanks for your help and hopefully this is clear.

Steve

Have you tried looking at the history APIs?

You can find information here : Process Instance | docs.camunda.org

1 Like

You can use this call and depending on the parameters you use you can get finished or unfinished instances currently running.

To get completed processes you could run this
http://localhost:8080/engine-rest/history/process-instance?finished=true
And for still running instances
http://localhost:8080/engine-rest/history/process-instance?unfinished=true

Thanks Niall and Maroun!!!

Niall - There is always an easier way than how I originally see it. Thanks for pointing it out to me!!