You can cycle through any container, whether bags on your person, in the bank, the guildbank slots or even what you are wearing ( I think ).
This link should point you in the right direction .. browse around and look for sample code to try in your addon.
https://wow.gamepedia.com/World_of_Warcraft_API#Bags
This is specific to what you are asking..
https://wow.gamepedia.com/API_GetContainerItemID
https://wow.gamepedia.com/BagID