How to get keyframes and related information? I'm a bit (or more...) lost about keyframes and fcurves information even if I have read this question and answers or others and tried to understand the related documentation.

What I'm trying to do is the following:


Looping along frames which have keyframes set on them (only these frames)
For each keyframe retrieve the related keyed objects (I'm interested in objects and bones only) and retrieve the keyframe information (location, rotation or scale only)


How to do that in Python?
I think it's something like that :

import bpy

for ob in bpy.context.scene.objects :
    if ob.type in ['MESH','ARMATURE'] and ob.animation_data:
        for fc in ob.animation_data.action.fcurves :
            if fc.data_path.endswith(('location','rotation_euler','rotation_quaternion','scale')):
                for key in fc.keyframe_points :
                    print('frame:',key.co[0],'value:',key.co[1])


Keyframe in blender are not store in one place. It's store on action related to object. You can look throw all keyframe on your blend file in bpy.data.actions. To filter by object type you have to look throw objects in your scene and find the related action