I haven't tried that in practice, but looking at limitations with historical data https://interactivebrokers.github.io/tws-api/historical_limitations.html#non-available_hd I can suppose you can't get market depths in a historical manner.
The maximum granularity you can get is 30-sec bars (open, high, low and close prices. may be with volume).
IB have a small possibility to suscribe on, receive and store tick-by-tick data,
but it's not the main purpose of that api.