Below are the steps to utilize the Vimeo oEmbed API in Node.js:
Install the axios
library using the following command in the terminal:
npm install axios
Import axios
and querystring
modules in the Node.js app:
const axios = require('axios');
const querystring = require('querystring');
Set the Vimeo API endpoint URL and video ID:
const vimeoEndpoint = 'https://vimeo.com/api/oembed.json';
const videoId = '123456789';
Create a querystring with the parameters required by the Vimeo API:
const params = querystring.stringify({
url: `https://vimeo.com/${videoId}`,
format: 'json'
});
Send the GET request to the Vimeo API endpoint using the axios
library:
axios.get(`${vimeoEndpoint}?${params}`)
.then(response => console.log(response.data))
.catch(error => console.log(error));
The response from the Vimeo API will contain the oEmbed data for the requested video.
{
type: 'video',
version: '1.0',
provider_name: 'Vimeo',
provider_url: 'https://vimeo.com/',
title: 'Video Title',
author_name: 'John Doe',
author_url: 'https://vimeo.com/johndoe',
is_plus: '0',
account_type: 'basic',
html: '<iframe src="https://player.vimeo.com/video/123456789" ... ></iframe>',
width: 640,
height: 360,
duration: 78,
description: 'Video Description',
thumbnail_url: 'https://i.vimeocdn.com/video/123456789_640.jpg',
thumbnail_width: 640,
thumbnail_height: 360
}
Asked: 2023-07-11 02:26:47 +0000
Seen: 10 times
Last updated: Jul 11 '23