Set collection for Store Product Gallery on dynamic page

The standard Store Product Gallery requires a manually configured store collection.
Rather than create static pages for each store collection I’d like to use dynamic pages and have the content automatically set, which basically means that the collection needs to be updated based on the dynamic page’s input.
Happy to write a bit of code to do this. Is there an API that allows me to set/update the chose collection?