How to loop over the API for creating a generative code?
You can take advantage of the dir() method in python to access "public" attributes of any object. You can use it for each modifier in the selected object :

import bpy

obj = bpy.context.object

for mod in obj.modifiers:
    print(mod.name, 'Modifier')
    for attr in dir(mod)[4::]:  # We skip the first 4 attributes which are internal
        print('  ', attr, ' --&gt; ', getattr(mod, attr))


Exemple with an object with an 'Array' and a 'Curve' modifier :