What is the Python script to create nodes?
Here is a repo that does exactly what you want. It has a ready-to-run python script that can be run from the command line in the background without opening the blender GUI. It creates a water material on a surface mesh for a convecting bubble - this is done with 2 different shaders and mixing them using a mixer shader. The script loops through the different files and renders the images as jpeg. The images are also there in the repo. Just clone the repo and run the command given in the README file in the terminal. This scripting was done with Blender v2.78.

https://github.com/nataraj2/BlenderScripting