1

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?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Bender
  • 49
  • 6

1 Answers1

2

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"]
ahammond
  • 31
  • 6