If you just want to return the latest value of the heartbeat use DescribeWorkflowExecution API call. Among other data the result of this call includes the list of pending activities which includes the heartbeat data for each activity.
Here is a code that executes that API.