The response object is not a dictionary; you cannot use its indexing.
If the API returns a JSON response, you need to use response.json() to decode it to a Python object:
data = response.json() print("respone is: ", data['result'])
Note that you do not need to encode JSON request data; you can just use the json argument to the request.post() method here; this also sets the Content-Type header for you:
response = requests.post(url, json=payload, auth=auth)
Last but not least, if the API uses JSONRPC as the protocol, you can use the jsonrpc-requests project to call the proxy method for you
from jsonrpc_requests import Server url = "http://public.coindaddy.io:4000/api/" server = Server(url, auth=('rpc', '1234')) result = server.get_running_info()
source share