How to make an object transparent in the viewport?
One option is to set the alpha value (fourth component) of Material.diffuse_color:

float array of 4 items in [0, inf], default (0.8, 0.8, 0.8, 0.8)

import bpy

# Get the object in context
obj = bpy.context.object

# Get the active material
mat = obj.active_material

# Set the alpha value of the diffuse color
mat.diffuse_color = (0.0 , 0.0 , 1.0 , 0.7)