Reputation: 69
I have this Python script:
import json
from cinbase.walle.client import Client
apiKey = foo
mysecret = bar
client = Client( apiKey, mySecret )
price = client.get_spot_price(currency_pair = 'BTC-EUR')
This is my output:
{
"data" :{
"amount": "123455"
"currency": "EUR"
}
}
How to get only "amount" value?
Upvotes: 1
Views: 84
Reputation: 31
In python, this data type is called a dict (short for dictionary). You can index this object as follows:
value = your_dict[key]
So in your case specifically:
amount = price["data"]["amount"]
Upvotes: 2