How to subdivide mesh with Python and Blender 2.8?
bmesh equivalent

Using bmesh can manipulate a mesh in either object or edit mode.

There is generally a bmesh operator equivalent of bpy.ops.mesh... in this case


  bmesh.ops.subdivide_edges()
  
  Subdivide Edges.
  
  Advanced operator for subdividing edges with options for face
  patterns, smoothing and randomization.


An example of 1 cut subdividing all edges of the context objects mesh.  Select a mesh object run the script in object mode.

import bpy
import bmesh

context = bpy.context
ob = context.object
me = ob.data
# New bmesh
bm = bmesh.new()
# load the mesh
bm.from_mesh(me)

# subdivide

bmesh.ops.subdivide_edges(bm,
                          edges=bm.edges,
                          cuts=1,
                          use_grid_fill=True,
                          )

# Write back to the mesh

bm.to_mesh(me)
me.update()


To use bmesh in edit mode, load the bound edit mesh, (instead of new and from_mesh)

bm = bmesh.from_edit_mesh(me)


write back (instead of to_mesh)

bmesh.update_edit_mesh(me)


How to use &quot;bmesh.ops.subdivide_edges&quot; on selected edges

Subdividing cubes at different intervals