You can translate the document:

Introduction

The YouTube Data API allows you to incorporate functions normally executed on the YouTube website into your own website or application. In this document we will explain how to integrate the Youtube API with Denodo using Youtube´s API search method and also how to configure Denodo´s pagination with this API.

Getting the API Key

First, to access the API, we must get the API key following these steps:

  1. Login into Google Developers Console and create a New Project.
  2. Once we have created a new project, on its dashboard we click on “Explore and enable APIs”.

  1. There, go to “Library” and we can search for “youtube data api v3”.

  1. Click on the search result to enable the API.
  2. Once it is enabled, go to the Credentials section and create a new credentials API key. Also, to get the Api key value we just have to click on “show key”.

API Limits

Note that projects that enable the YouTube Data API have a default quota allocation of 10,000 units per day and all API requests, including invalid requests, incur a quota cost of at least one point (Quota Calculator).

Integration in Denodo

Connecting to the API

Data source

Youtube´s API is a REST API and returns responses in JSON format. So the first step to integrate Youtube´s API is to create a JSON data source. To create the JSON data source, go to File > New > Data source and select JSON(HTTP/OpenAPI).

The Tool will display the dialog to create the data source:

  1. Data route: HTTP client.
  2. Base URL: https://www.googleapis.com/youtube/v3. This URL has been obtained from the API documentation.

Pagination

In the data source we also have to configure the pagination as the API returns the results of the search paginated. We have to specify the parameter in the URL for the next token (pageToken) and the path to the next token in the JSON response (nextPageToken).

The parameter in the URL for the next token is a parameter that will be added to the URL with the token of the next page and the path to the next token is the path in the JSON response where the token is located.

Finally, we establish the maximum number of requests (it is recommended to use a number of requests that do not exceed the API limit).

Base view

Once the data source is created, we have to create a base view to make the search API requests.

  1. Create a base view from the data source.
  2. Relative URL: /search?&q=@query&type=@type&key=@apikey&part=snippet 

In the relative URL we need to introduce the nex parameters:

  • q: The q parameter specifies the query term to search for.
  • key:  API key.
  • part:  The part parameter specifies a comma-separated list of one or more search resource properties.
  • type: The type parameter restricts a search query to only retrieve a particular type of resource (video, channel, playlist).

These are the basic parameters to make requests to the API, you can use more parameters for filtering the results, that are specified in the documentation.

  1. Finally, we specify the tuple route: /JSONFile/snippet which is in the following screenshot to get the item's details flatten. This is the JSON route to access item details.

  1. After creating the view, we edit it to change data type values of: publishedat to timestamp.

Final result

Derived view

From the base view created, we can create a derived view to select the output fields that we want to get in the final result.

  1. Click on the base view and go to New > Selection.
  2. Where Conditions: we have to introduce our api key.

  1. Output: we check the boxes of the fields that we want to remove and after that, click on “Remove”.

  1. In this example, we have selected the fields shown in the screenshot.

Expected result

The following image shows the execution of the query: data and type: video. There, we can see: the query, publication date, the title, channel name, resource type and the video id. In relation to the pagination, we have sent 10 requests that return 5 items per page.

References

Getting  the API key

API Documentation

API Quota costs

Pagination

Disclaimer
The information provided in the Denodo Knowledge Base is intended to assist our users in advanced uses of Denodo. Please note that the results from the application of processes and configurations detailed in these documents may vary depending on your specific environment. Use them at your own discretion.
For an official guide of supported features, please refer to the User Manuals. For questions on critical systems or complex environments we recommend you to contact your Denodo Customer Success Manager.
Recommendation

Questions

Ask a question

You must sign in to ask a question. If you do not have an account, you can register here