I am trying to get the bid and ask price for an options contract using the yahoo finance API, however, the JSON output is difficult to navigate.
import requests
url = requests.get("https://query1.finance.yahoo.com/v7/finance/options/AAPL").json()
url
There a multiple contractSymbol such as:
'contractSymbol': 'AAPL190503C00150000'
'contractSymbol': 'AAPL190503C00155000'
and it returns this associated data for each contractSymbol.
{'contractSymbol': 'AAPL190503C00150000',
'strike': 150.0,
'currency': 'USD',
'lastPrice': 54.31,
'change': -1.579998,
'percentChange': -2.826978,
'volume': 105,
'openInterest': 35,
'bid': 52.25,
'ask': 54.85,
'contractSize': 'REGULAR',
'expiration': 1556841600,
'lastTradeDate': 1556306875,
'impliedVolatility': 1.4033232958984376,
'inTheMoney': True}
I am only trying to recover the 'bid and 'ask' for each contractSymbol, however, it seems to be nested very far into the json and I am having a lot of trouble.