How to get/calculate RTT (Round-Trip Time) between two nodes with Consul API

There is a “consul rtt [options] node1 [node2]” command which gives rtt between two nodes.

I wanna do this with Consul API and bash/python. How should I get/calculate it?

I found this in the Go part of the Consul code :

For Python: