Im using requests with the Bitmex API, im trying to get the lastPrice value from the get requests.
I stored the response into a variable, tried a few ways into pulling the lastPrice value including print(value[1]) print(value['lastPrice'], all of which didnt work, ive been reading for a while now on here and cant seem to find the correct working way to get the value. sorry if this is asked all the time.
import requests
r = requests.get('https://www.bitmex.com/api/v1/instrument?symbol=XBT&columns=lastPrice&count=1&reverse=true')
value = r.text
print(value)
#print(value[1])
#print(value['lastPrice'])
The output from this is
[{"symbol":"XBTUSD","timestamp":"2019-10-03T22:37:13.085Z","lastPrice":8190.5}]
using value[1] just returns the first letter in the print. So for ex [1] returns { and using ['lastPrice'] returns
TypeError: string indices must be integers