[obj.keyframe_insert, bpy.data.particles["ParticleSettings"].lifetime]; how to insert keyframe to an existed particle setting, e.g lifetime

I am trying to randomize some values of selected objects in blender How can I keyframe_instert of the active particle properties? I can do it with clicking "I" of the desired area and it works (creates a keyframe)

I tried: (n

obj = bpy.context.active_object


gave type errors both

TypeError: bpy_struct.keyframe_insert() property "lifetime" not found



Set on the object that has the property

Python console code. A default particle system has been added to a Plane that has context.

The lifetime is set to 10 and keyframed on frame 1.

>>> C.object
bpy.data.objects['Plane']

>>> ps = C.object.particle_systems['ParticleSettings'].settings
>>> ps
bpy.data.particles['ParticleSettings']


Notice the objects particle systems settings points to its data item in bpy.data.particles which is the ID object that the action (typically bpy.data.actions['ParticleSettingsAction']) will belong to.