You should implement new functionality in a plugin (site plugin or dedicated plugin) or the theme (when it is mostly used for displaying data).
In your case I think you should create a new plugin named “Instagram User Feed” and require that library from that plugin and also put the code for using that library, registering Gutenberg blocks, shortcodes, widget, etc.