As batFINGER suggested in his comment. This can be done using bpy.ops.anim.keyframe_clear_v3d()
. To do this in python you need to select the bone first then apply the operation. Below is a script to delete animation of a specific bone, in this example, a bone named 'Bone' will have its animation deleted:
import bpy
arm = bpy.data.objects['Armature']
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.object.select_all(action='DESELECT')
arm.select = True
bpy.context.scene.objects.active = arm
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_all(action='DESELECT')
for pb in arm.pose.bones:
if pb.name == 'Bone':
arm.data.bones[pb.name].select = True
bpy.ops.anim.keyframe_clear_v3d()
bpy.ops.object.mode_set(mode='OBJECT')