This script does not do any unwrapping. List of available nodes
import bpy
mat_name = "MyMaterial"
image_path = #...
mat = (bpy.data.materials.get(mat_name) or
bpy.data.materials.new(mat_name))
mat.use_nodes = True
nt = mat.node_tree
nodes = nt.nodes
links = nt.links
# clear
while(nodes): nodes.remove(nodes[0])
output = nodes.new("ShaderNodeOutputMaterial")
diffuse = nodes.new("ShaderNodeBsdfDiffuse")
texture = nodes.new("ShaderNodeTexImage")
uvmap = nodes.new("ShaderNodeUVMap")
texture.image = bpy.data.images.load(image_path)
uvmap.uv_map = "UV"
links.new( output.inputs['Surface'], diffuse.outputs['BSDF'])
links.new(diffuse.inputs['Color'], texture.outputs['Color'])
links.new(texture.inputs['Vector'], uvmap.outputs['UV'])
# distribute nodes along the x axis
for index, node in enumerate((uvmap, texture, diffuse, output)):
node.location.x = 200.0 * index