Scripting keyframes

I’m trying to script keyframes for the camera. Location is easy, but I can’t figure out how to do it for the LimitDistance constraint.
What do I need to add to get to the constraint?

scene = bpy.context.scene
camera = scene.objects[‘Camera’]

camera.location = (5, -8, 9)
camera.keyframe_insert(datapath=‘location’, frame=1)

camera.location = (1, -1, 1)
camera.keyframe_insert(datapath=‘location’, frame=10)

Thanks,
Dave

Ah, I figured it out!
Unless there is a better way to do this?

import bpy

scene = bpy.context.scene

camera = scene.objects[‘Camera’]
distConstr = camera.constraints[‘Limit Distance’]

camera.location = (5, -8, 9)
distConstr.distance = 15.0

camera.keyframe_insert(data_path=‘location’, frame=1)
distConstr.keyframe_insert(data_path=‘distance’, frame=1)

camera.location = (1, -1, 1)
distConstr.distance = 5.0
camera.keyframe_insert(data_path=‘location’, frame=10)
distConstr.keyframe_insert(data_path=‘distance’, frame=10)

On a related note.
Is there a way to do something in the GUI, and get the equivalent python code somehow?
That would very useful.