Delete the upper surface of a cylinder with the api
Bmesh script.
can add primitives using bmesh.  The equivalent of add cylinder is bmesh.ops.create_cone(...) with both radii set to match.
As with the mesh operator the default for ends is NGON fill.
The top face will have a normal that is in +Z direction.
https://blender.stackexchange.com/a/96121
Test script, run in OBJECT mode.
import bpy
import bmesh

context = bpy.context

TOL = 1e-5

me = bpy.data.meshes.new(&quot;Open Cylinder&quot;)
bm = bmesh.new()
bmesh.ops.create_cone(
        bm,
        cap_ends=True,
        segments=32,
        diameter1=3,
        diameter2=3,
        depth=0.02,
        calc_uvs=True,
        )

f = next(
        (
            f for f in bm.faces
            if f.normal.angle((0, 0, 1)) &lt; TOL
        ),
        None
        )
        
if f:
    bm.faces.remove(f)        

        
bm.to_mesh(me)
ob = bpy.data.objects.new(&quot;Open Cylinder&quot;, me)
context.collection.objects.link(ob)

For the case of a TRIFAN filled end would remove the middle vert, to remove the edges and faces in one fell swoop.
Alternatively could create cylinder without faces and fill only the bottom edge loop.