Baking script

I’m trying to write a small script that allows me to automate the process of baking high-poly models into low-poly ones. Is it possible to control this via Python? I started applying the decimate modifier, but i have no idea of how to automate the rendering process. Also, is there any modifier to UV the mesh?