How to select two objects add a boolean modifier and enter name for object to be unioned
Modifiers are stored in an object's modifier list and a new one can be added by calling obj.modifers.new(name, type). To adjust the modifier settings you can either collect the created modifier object returned by the new method or access it through the list.

import bpy

target_obj = bpy.data.objects['Cube']
cutter_obj = bpy.data.objects['Sphere']

bool_mod = target_obj.modifiers.new('cutter', 'BOOLEAN')

bool_mod.object = cutter_obj
bool_mod.operation = 'DIFFERENCE'

# or directly -
bpy.data.objects['Cube'].modifiers[0].object = bpy.data.objects['Sphere']