modifying fcurve modifiers in python?
Adding a modifier to an FCurve is much like adding a modifier to an Object, you first add it, then you adjust the properties.

Adding the Modifier + Setting properties

Here is shown how to add a modifier to an existing fcurve for an object, but it's very similar when the subject is a keyframed property of a shader tree.

import bpy

obj = bpy.data.objects['Plane']

# pick the fcurve to add to
fcurve = obj.animation_data.action.fcurves[0]

# add a modifier and get a reference.
limits = fcurve.modifiers.new(type='LIMITS')
limits.use_max_x = True
limits.max_x = 0.23
limits.use_influence = True
limits.influence = 0.5


The shadertree version

mat = bpy.data.materials['some_material']
fcurve =  mat.node_tree.animation_data.action.fcurves[0]


The attributes of the modifier can be found by 


hovering over the UI elements and reading the tooltip
using the Python Console and use the auto-complete feature to dig through the list of attributes. (admittedly not very graceful)


Normally you don't need to set all possible properties of the modifier, the modifier will come with all its default values set (just like when you add via the GUI). The properties are named fairly logical and the above methods of finding the properties should be sufficient.

Picking  the FCurve

Picking the FCurve from the UI is direct, but using a script to pick the FCurve will take some practice. Luckily there's a method to get fcurve by name and index.

# to get a reference to an fcurve for location, specifically the
# x component. index 0 is x.
action.fcurves.find('location', index=0)




or for materials with keyframed node properties

fcurves = mat.node_tree.animation_data.action.fcurves

# get the reference this way
fcurve = fcurves.find('nodes["Emission"].inputs[1].default_value')
# &gt;&gt; bpy.data.actions['Shader NodetreeAction']...FCurve


Figuring out what to use in the fcurves.find() method, can involve doing a little experimenting (a dry run) and first see what fcurves[your index].data_path returns. Or use the UI and read what the Active F-Curve says:



for the materials..