# Get Temporal History Programmatically in Java

**URL:** <https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [June 1, 2023, 3:11am UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411 "2023-06-01T03:11:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome\_John](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jerome_john/32/3267_2.png) [@Jerome\_John](https://community.temporal.io/u/Jerome_John)\
**Post date:** [June 1, 2023, 3:11am UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411/1 "2023-06-01T03:11:35Z")

</div>

Hi, in Temporal UI, there’s a history tab that shows a lot of workflow execution details in json format.  
How do I access these details using the java-sdk. Is there a method that I can call to get all these details?  
Thanks!

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [June 2, 2023, 3:26pm UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411/2 "2023-06-02T15:26:53Z")

</div>

```auto
    WorkflowServiceStubs service = WorkflowServiceStubs.newServiceStubs(stubOptions);
    service.blockingStub().getWorkflowExecutionHistory(...);

```

---

<div class="post-metadata">

**Author:** ![Chad\_Retz](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/chad_retz/32/1396_2.png) [@Chad\_Retz](https://community.temporal.io/u/Chad_Retz)\
**Post date:** [June 2, 2023, 10:43pm UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411/3 "2023-06-02T22:43:12Z")

</div>

Note, in newer versions of the SDK we have high level wrappers for this now. See [WorkflowClient.fetchHistory](https://www.javadoc.io/static/io.temporal/temporal-sdk/1.19.1/io/temporal/client/WorkflowClient.html#fetchHistory(java.lang.String)) and even the more advanced [WorkflowClient.streamHistory](https://www.javadoc.io/static/io.temporal/temporal-sdk/1.19.1/io/temporal/client/WorkflowClient.html#streamHistory(java.lang.String)). [WorkflowClient.listExecutions](https://www.javadoc.io/static/io.temporal/temporal-sdk/1.19.1/io/temporal/client/WorkflowClient.html#listExecutions(java.lang.String)) + these are often used to build tooling to run the replayer.

---

<div class="post-metadata">

**Author:** ![Jerome\_John](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/jerome_john/32/3267_2.png) [@Jerome\_John](https://community.temporal.io/u/Jerome_John)\
**Post date:** [June 3, 2023, 5:04pm UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411/4 "2023-06-03T17:04:35Z")

</div>

I tried that one, and also this:

```auto
GetWorkflowExecutionHistoryRequest request =
    GetWorkflowExecutionHistoryRequest.newBuilder()
        .setNamespace(NAMESPACE)
        .setExecution(workflowExecution)
.build()

GetWorkflowExecutionHistoryResponse result =
    service.blockingStub().getWorkflowExecutionHistory(request)

String jsonHistory = JsonFormat.printer().print(result.getHistory())

```

But when I compare it to Temporal UI history tab, I’m not getting some of the fields there. Is the one in UI has a custom formatting?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [June 5, 2023, 2:55pm UTC](https://community.temporal.io/t/get-temporal-history-programmatically-in-java/8411/5 "2023-06-05T14:55:15Z")

</div>

Their format is different I believe, what fields are you missing and from which side?  
Would use the json you get from WorkflowExecutionHistory as “source of truth” as well as use it in WorkflowReplayer.
