It is not complicated at all. Hugo’s internal shortcodes use the public oEmbed API.
You can have a look at each internal shortcode over here
For a tweet the oEmbed URL is in the form of: https://api.twitter.com/1/statuses/oembed.json?id=<enter-tweet-id>
It’s the same for Instagram: https://api.instagram.com/oembed/?url=https://instagram.com/p/<insert-post-ID>
Also note that you may want to have a look at the Simple Shortcodes that can be enabled via the privacy config if you plan to do this for Instagram.