How to get the completed tasks

Hi there,
Is there any API to get the completed tasks,in camunda
I am using all the below APIs like
task=taskService.createTaskquery()
taskService.claim(task.getId(),“vamsi”);
taskService.complete(task.getId());

Now i would like to get that completed task.Is there any API or any method to get

You can query for historic task instances using History Service API.

execution.getProcessEngineServices().getHistoryService().createHistoricTaskInstanceQuery().finished().list();

Also, you can query filters to the above code like filtering by process definition key or tenant, etc.

Same thing can be achieved by REST API also,

1 Like

Thank you aravindhrs…can you give be the code for filtering by process difinition key…

Here it is, pass the processDefinitionKey in below api.

execution.getProcessEngineServices().getHistoryService().createHistoricTaskInstanceQuery().processDefinitionKey("").finished().list();