Key visibility Maya Python API

How can “visibility” of a mesh can be keyed at a frame using Maya Python API ( I guess using OpenMayaAnim module) ?

Found it!
It can be done using OpenMayaAnim.MFnAnimCurve()

why not just do it via maya.cmds though? It’s less work I’d imagine