Get URL for embedding Instagram videos from API

I am trying to find an embed soft link for an Instagram video. Unfortunately, Instagram seems to have oEmbed endpoint, treats the video as photos and returns only the keyframe image, and does not provide a link for embedding.

Does anyone know how to get a link to embed an instagram video without having to manually visit the page for this video?

+7
api video embed instagram
source share
2 answers

According to the API schema site, a GET / media / media-id request for a video object returns a JSON object with the information needed in "data.videos.low_resolution.url".

I have successfully embedded the video returned by their sample into a web page with the following code:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Video Embed Test</title> </head> <body> <video width="480" height="480" controls> <source src="http://distilleryvesper9-13.ak.instagram.com/090d06dad9cd11e2aa0912313817975d_102.mp4" type="video/mp4"/> </video> </body> </html> 
+9
source share

I couldn’t find a way to get the embed URL, however, by studying Instagram instilled by it, I was able to determine how to create it based on the information provided by the Media API endpoint. Basically, you just need to add /embed/ at the end of the short URL for part of the medium. Therefore, in a Django template, it will look something like this:

 <iframe src="{{ media.short_link }}embed/" width="612" height="710" frameborder="0" scrolling="no" allowtransparency="true"></iframe> 

As an interesting note, I also found that you can change the width and height of the embed code, and it works without any problems (at least when you only reduce the size by half, I haven’t tried anything else).

+5
source share

All Articles