Is there a way to create widget instance using API?

Without the user interaction, is there a way to create a widget instance?

Find the widget in the document and clone it.

Sorry, I meant how to create the first instance i.e. if the document doesn’t have a widget yet.
For example, if the selection has changed, I want to insert an instance. How do I achieve that?

The plugin cannot create WidgetNodes. The only possible way is to clone already existing nodes in the file.