Do I need to update sockets of InvokeSubprogramNode from script
I still plan to make it easier for other addons to use AN so anything I say here might change in the future, not very soon though.

Before you can create the sockets in the Invoke Subprogram node you need to do three things:


Create the subprogram itself (loop, group, script)
Tell the Invoke Subprogram node which subprogram it has to invoke:

invokeSubprogramNode.subprogramIdentifier = loopInputNode.identifier

Every node has an unique identifier (some random string) and every subprogram has an identifier. The identifier of a subprogram is the identifier of its 'owner' node. 'Owner' nodes are: Loop Input, Group Input, Script. Every subprogram has to have exactly one of those.
Update the sockets sockets in the Invoke Subprogram node by calling this function: https://github.com/JacquesLucke/animation_nodes/blob/master/nodes/system/subprogram_sockets.py#L12

animation_nodes.nodes.system.subprogram_sockets.forceSubprogramUpdate()


Alternatively you can also integrate your code into a Template, which is a special class that makes it easier to create node groups programatically.

Here is an example of a template: https://github.com/JacquesLucke/animation_nodes/blob/master/templates/arrange/distribute_instances_on_spline.py

Even if you don't want to subclass a class of AN you can see how the nodes are created there.