Fetching Youtube Metadata
Mention allows to find relevant posts on the web and social media, using complex filters including keyword-based boolean queries, keyword proximity constraints, influence scores, author country, language, etc.
However, the Youtube policies do not allow us to return the full Youtube metadata in our API (e.g. title, description, author), like we do in our applications.
Because of this, the API will return no other metadata than the ID and URL of the Youtube video.
This guide explains how to fetch the metadata of relevant Youtube video found by the Mention API.
Overview
Fetching the metadata of relevant Youtube video found by the Mention API can be done by using the official Youtube API.
This does not incur any additional cost.
Obtain an API key and enable Youtube Data service
Accessing the Youtube API requires to have an API key.
You must click on Create Credentials.
Then click on "Create Project" on the credentials page.
You’ll be taken to a screen where you can add a project name, select your organization, and select a location (URL).
You can create a project without an organization. If you don’t have an organization, you won’t be prompted to select a location.
Click on "Create".
On the next page, at the top, click on "Create credentials" then select "API key".
Copy the API key somewhere.
Now go to the top left of the screen and click on "Enabled APIs and services".
At the top, click on "Enable APIs and services".
Search for "youtube".
Select "Youtube Data API v3".
Click on "Enable"
Access the Youtube video data
Using a Youtube mention found by the Mention API, use the unique_id
field and find the id of the video to use in the Youtube API
The unique_id
field is formatted as follows: youtube:uDlZyyIs_cA
. You just have to remove the youtube:
part to get the Youtube video id.
Now is time to use the copied API key.
To get the details of the Youtube video, use the following URL with the corresponding parameters:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=YOUR_VIDEO_ID&key=YOUR_API_KEY
That's all!