# API Response

The Terra protocol is implemented through various modules, each exposing its own API. The Terra instance follows the modular organization of Terra Core and organizes functions into namespaces identified by the name of the module that it concerns.

Every method that invokes an API call returns back an ApiResponse object, which wraps the actual result. This object can be used anywhere its underlying object is expected without unwrapping it, except for type checking, where you should prefer using isinstance() over direct type comparison.

tax_rate = terra.treasury.tax_rate()
type(tax_rate) == Dec # -> False
type(tax_rate.__result__) == Dec # -> True
isinstance(tax_rate, Dec) # -> True

tax_rate * 2 # -> double the tax rate, no unwrapping needed.

# Block Height

You can retrieve the block height that was reported for the result. Note that not all method calls will report back height, so you may need to test for None.

tax_rate.__height__ # -> 1020310

# Request

You can get the requests.Request object used to build request.

request = tax_rate.__request__
request.url # -> url used for request

# Response

If you want the original requests.Response object before it was parsed by Jigu:

response = tax_rate.__response__
response = response.content # -> original content
Updated on: 3/4/2020, 7:47:53 AM