Considering Cylinder
API document: bpy.ops.mesh.primitive_cylinder_add(vertices=32, radius=1.0, depth=2.0, end_fill_type='NGON', view_align=False, enter_editmode=False, location=(0.0, 0.0, 0.0), rotation=(0.0, 0.0, 0.0), layers=(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
apparently there is no way to construct what you want directly using cylinder parameters because there is only one point as the centre point (location) not endpoints.
solution 1) You will need to find rotations for rotation parameter of cylinder. If you have them you just simply set the location of cylinder as centre of your endpoints; set rotation values; the depth will be the distance between the endpoints.
solution 2) However, you may simply draw a line between the endpoints and apply blending. It will be a cylinder.
bpy.ops.curve.primitive_bezier_circle_add() #for blending
obj = bpy.context.object
bpy.ops.curve.primitive_bezier_curve_add() # a curve, your endpoints for example
bpy.context.object.data.bevel_object = bpy.data.objects[obj.name] #a cylinder