i used ib insync (python)
def chains(self, symbol):
stock = Stock(symbol, 'SMART', 'USD')
ib.qualifyContracts(stock) # need this for conId
chains = self.ib.reqSecDefOptParams(symbol, '', stock.secType, stock.conId)
filtered_chains = next(c for c in chains if c.exchange == 'SMART')
return filtered_chains