Get video from VKontakte Api

Hi everyone) such a problem - I can't get a link to the video. There is access_key, vid, owner_id. I get all this from newsfeed. Moreover, on the VK documentation page, if you simply enter owner_id in the field for checking the request, then it gives the entire list of videos of this user/group without any problems, but if you set videos, then you get a response like

response: {
count: 1,
items: []
}

I.e., items is empty. And I tried both with and without access_key. Who has already done this, tell me what is wrong with me?

Author: Deleted, 2014-01-17

5 answers

That's it, I figured it out. The Russian version of the API documentation has an incomplete description. Use the English version!

 4
Author: alexruden, 2014-01-17 10:05:53

Usually, the VK does not give a direct link to the video

This is because you use the request header "User-Agent", if it is empty, then there will be direct links in files. Make a request like:

Https://api.vk.com/method/video.get?videos=-53956136_169543800&access_token=%access_token%

With an empty "User-Agent" header, it will exit:

{
    'response' : [1, {
            'duration' : 1452,
            'vid' : 169543800,
            'views' : 4790,
            'owner_id' : -53956136,
            'player' : 'https://vk.com/video_ext.php?oid=-53956136&id=169543800&hash=06da65ec2f1a6d00',
            'date' : 1408830421,
            'link' : 'video-53956136_169543800',
            'files' : {
                'mp4_240' : 'https://cs543208.vk.me/u222975331/videos/fd8d6c3d4d.240.mp4?extra=d1xg726trlMQIwAZ4X8NTUJRI2kk-uw9TJ66bWZtq_odwiDxYverCALb8PNb_z-zjbPhvX07ftxnZRXZ-li8XiFKJZ_oEJnbrPVPqLrKUiFM9J1FfYFEEm3c5SfRXRDSSU29k7QTkS_7uTxg',
                'mp4_720' : 'https://cs543208.vk.me/u222975331/videos/fd8d6c3d4d.720.mp4?extra=d1xg726trlMQIwAZ4X8NTUJRI2kk-uw9TJ66bWZtq_odwiDxYverCALb8PNb_z-zjbPhvX07ftxnZRXZ-li8XiFKJZ_oEJnbrPVPqLrKUiFM9J1FfYFEEm3c5SfRXRDSSU29k7QTkS_7uTxg',
                'mp4_360' : 'https://cs543208.vk.me/u222975331/videos/fd8d6c3d4d.360.mp4?extra=d1xg726trlMQIwAZ4X8NTUJRI2kk-uw9TJ66bWZtq_odwiDxYverCALb8PNb_z-zjbPhvX07ftxnZRXZ-li8XiFKJZ_oEJnbrPVPqLrKUiFM9J1FfYFEEm3c5SfRXRDSSU29k7QTkS_7uTxg',
                'mp4_480' : 'https://cs543208.vk.me/u222975331/videos/fd8d6c3d4d.480.mp4?extra=d1xg726trlMQIwAZ4X8NTUJRI2kk-uw9TJ66bWZtq_odwiDxYverCALb8PNb_z-zjbPhvX07ftxnZRXZ-li8XiFKJZ_oEJnbrPVPqLrKUiFM9J1FfYFEEm3c5SfRXRDSSU29k7QTkS_7uTxg'
            },
            'description' : 'Видео предоставлено группой [club53956136|AniZUR Аниме на любой вкус]<br><br>Следующая серия: http://vk.com/video-53956136_169543833',
            'comments' : 5,
            'title' : 'Hunter x Hunter Remake / Хантер x Хантер - 2 сезон 66 серия [Озвучка: Ancord]',
            'image' : 'http://cs543208.vk.me/u222975331/video/m_1a4f8d0d.jpg',
            'image_medium' : 'http://cs543208.vk.me/u222975331/video/l_7bbad3fc.jpg'
        }
    ]
}

If you need a permanent access_token(may be dangerous) here:

Https://oauth.vk.com/authorize?client_id=3087106&scope=wall,offline&redirect_uri=http://api.vk.com/blank.html&display=page&response_type=token

!Updated

The new VK API now requires a new mandatory parameter: API version: v=5.73(Current at the moment). And the full link will look something like this:

Https://api.vk.com/method/video.get?videos=-53956136_169543800&access_token=%access_token%&v=5.73

 2
Author: BladeMight, 2018-03-07 00:54:08

Look, here's a request like this:

Https://api.vk.com/method/video.get?v=5.12&videos=71057340_167884774_6e2f5cee5c04b2b898&access_token=myaccesstoken

I get this answer:

{
    response =     {
        count = 1;
        items =         (
                        {
                comments = 4;
                date = 1395082963;
                description = "::::::\U0418\U041d\U0424\U041e\U0420\U041c\U0410\U0426\U0418\U041e\U041d\U041d\U0410\U042f \U0412\U041e\U0419\U041d\U0410:::::::\n:::::http://vkontakte.ru/club4121067:::::";
                duration = 64;
                id = 167884774;
                "owner_id" = 71057340;
                "photo_130" = "http://cs540303.vk.me/u12911501/video/s_f1c9b9d6.jpg";
                "photo_320" = "http://cs540303.vk.me/u12911501/video/l_074712cb.jpg";
                player = "http://vk.com/video_ext.php?oid=71057340&id=167884774&hash=32fa35ec6b845a99";
                title = "\U041e\U0442\U0434\U044b\U0445 \U0432 \U041a\U0440\U044b\U043c\U0443 - 2014 \U0423\U043a\U0440\U0430\U0438\U043d\U0430. ";
                views = 707;
            }
        );
    };
}

Usually, the VK does not give a direct link to the video, although sometimes there are exceptions (they should be in the files dictionary). In this case, you have to use the link to the player and open it in the browser.

 1
Author: alexruden, 2014-03-18 07:30:50

This is because you use the request header "User-Agent", if it is empty, then there will be direct links in files.

It doesn't work at the moment. Access to the "files" section is possible only when you log in as a trusted application, or by parsing the page https://vk.com/dev/video.get

 1
Author: Max Walker, 2019-07-07 10:14:06

Maybe it's the video's owner_id. The owner_id parameter can be taken from the newsfeed.get data. That is, the owner_id of the video may differ from the source_id of the post that the video belongs to, since the video may be reposted by another group or user.

 0
Author: Iryna Tsimokhautsava, 2015-04-08 18:55:38