Creating path curve using python script
If you want to include the first and last coordinates you need to add the following lines after creating the curve:

spline.use_endpoint_u = True
spline.use_endpoint_v = True


so you finaly get:

def create_curve(coords_list):
    crv = bpy.data.curves.new('crv', 'CURVE')
    crv.dimensions = '3D'
    spline = crv.splines.new(type='NURBS')
    spline.points.add(len(coords_list) - 1) 
    for p, new_co in zip(spline.points, coords_list):
        p.co = (new_co + [1.0])
    spline.use_endpoint_u = True
    spline.use_endpoint_v = True
    obj = bpy.data.objects.new('object_name', crv)
    bpy.data.scenes[0].collection.objects.link(obj)