Step 2: Specify API Details
Request URL
In this field you will enter the GET
request URL. A GET
request is used to request data from an API.
For example, to retrieve videos from YouTube the GET
URL for the YouTube API is https://www.googleapis.com/youtube/v3/search
.
You can usually find the GET
URL from the developer documentation. For YouTube, we found that information here: https://developers.google.com/youtube/v3/docs/search/list
Authentication Method
Most APIs require authentication in order to access their data. We support three authentication methods:
- Bearer Token
- API Key
- Basic Authentication
- OAuth
You will select the authentication method that is supported by the API you are trying to pull data from. Once you select the relevant option you will see the additional fields needed to configure that authentication method. For example, if you select API Key you will enter a name for the key and then your alphanumeric API key.
If you are using the YouTube API, you will need to generate an API Key to give you access. You can see the instructions on how to do so in YouTube’s YouTube Data API Overview article , or follow these instructions:
- Log into the Google Developer Console .
- Create a new project by clicking Create New Project or by clicking on the name of the existing project you have open and clicking NEW PROJECT.
- Once you’re in your new project, click + ENABLE APIS AND SERVICES.
- In the API library, navigate to YouTube Data API v3.
- Click ENABLE.
- Then click CREATE CREDENTIALS and select the relevant settings.
- You will then see a page display with your API key.
You can create a sample call by entering https://www.googleapis.com/youtube/v3/videos?key=YOUR_API_KEY into your browser.
You can also see a sample call in the Sample partial request section of Youtube’s Data API Overview article.
Query Parameters
This is where you enter specific query parameters that you need to make a successful call. You can add any number of key, value pairs that we will append to your GET request as query parameters.
For YouTube this will include the following:
- part - this parameter is required for the Search endpoint and must be set to
snippet
. This is discussed in the YouTube API documentation under “Parameters” here . - type - this parameter specifies the resource type we would like to filter the results to. For our example, we will set this to
video
to make sure our response only includes information about video resources. - maxResults - this parameter specifies the number of videos you want returned per page. It is optional and will default to 5 if not specified, but let’s set it to 50. This way our preview data table in later steps will include 50 records instead of 5 (since we only show one response at a time in the preview table!)
- channelId - this parameter specifies the channel we would like to filter the results to. In the case of this example, the YouTube Channel ID for the Yext YouTube channel is
UCBGyMZqAKM1FDAAEOR3s8Ag
. This can also be located in the URL for the YouTube channel:
Headers
This is where you enter specific HTTP request headers that you need to make a successful call. You can add any number of key, value pairs that we will set as headers in your GET request.
For the YouTube Connector example, we actually do not need to set any specific Headers so we will skip this step and leave it blank!
Pagination Methods
Most API List endpoints support a pagination, meaning they will return the data you requested in multiple pages or responses. The API Documentation will typically let you know which pagination method the API uses and how you can fetch the additional pages.
We support four pagination methods:
- Cursor Pagination
- Page-Based Pagination
- Link Header Pagination
- Offset Pagination
The Youtube API’s Search endpoint uses cursor pagination, as discussed here .
When multiple pages exist, the nextPageToken
property will be included in the API response and includes a token that lets us know that another page of results exists. This is called the cursor. We will set nextPageToken
in the “Cursor” field so that we know to look for the cursor in the nextPageToken
property of each response from the YouTube API.
Sometimes the cursor is contained in the response header, but in this case, it is contained in the response body so we will set the “Detect Cursor In” field to Response Body
.
A cursor could be one of the following types: a token, a relative URL or a full URL. If the cursor is a token, it will be passed in the next API request using a query parameter so we must also know the parameter’s key (the “Page Key”). In this case, the YouTube API cursor is a token, and the key used to send that token in the next request is pageToken
. If the cursor is a full URL or relative URL, you do not need to specify a Page Key!
Lastly, you can optionally specify a Max Page Count. In this example, we want to fetch all of the videos from the Yext channel, so we will leave this blank.
JSON Type
Next you need to specify if the response will contain one entity or many entities. When you look at the sample response you will be able to see this. If the response contains a list of entities you will need to add the JMESPath Syntax for that entity container so we can identify and pull the nested data for each.
Assuming you filled out all of the details above, you can run a test call by clicking Pull at the top of the page. Then click on the View Raw Response button so you can view all the video data and confirm that your pull request was successful. You can also see that the YouTube API response contains multiple videos, so we will select “Many Entities” as our JSON Type.
As you can see in your Raw Response, video objects are nested under the items
section of the response, so enter items
as the Entity Container.