Is it possible to create an animation in Blender 2.8, using Python, that it's not tied to any object?
There is a related question here (Is it possible to create instance with different scale animation data but the same mesh with python?), but I will expand on it:

Once a new action has been created, and an Fcurve for it, using keyframes_insert does not work (it produces the error pasted in the question). Using `keyframes_points.add(count=X), does work, and later the frame number of value can be set with:

keyframe_point.co = (frame_number, value)


For example (taken from the link above):

def random_scale_action():
action = bpy.data.actions.new("RandomScaleAction")
data_path = "scale"
# (frame, value) for keyframe point
for axis in [0, 1, 2]:
    # new fcurve
    fc = action.fcurves.new(data_path, index=axis)
    # add a new keyframe point
    # OPTION 1: IT WORKS!
    fc.keyframe_points.add(count=2)
    for kfp in fc.keyframe_points:
        kfp.co = (uniform(1,100), uniform(0, 1))
    # OPTION 2: does NOT work, and produces the error pasted into the question(above)
    fc.keyframe_insert(data_path, index=axis, frame=uniform(1,100))

return action