My name is Jamie and I am currently attending UNC-CH’s Coding Bootcamp! I started on November 1, 2016 and it is insane the amount of information that I have learned in just a little over 2 months… Although challenging at times, I am so happy that I decided to pursue this path!
This past Saturday we had a guest speaker from Thoughbot’s Raleigh office and he discussed a number of really awesome things, but one thing that he suggested that we should do (as new developers) is start a blog! So here I am! 🙂
The first thing I wanted to share was in regards to the YouTube API. Last week I spent about 5-6 hours scouring the internet trying to figure out how to do an AJAX call! But I figured it out… and I felt like a genius!
To give you some background, I am doing a group project and we have to include two APIs. We are creating an app that allows you to enter ingredients that you have at home and get recipes and instructional videos. It is looking vey nice! Not quite done, but very close!
There are two things I needed to accomplish with this API:
- Make an AJAX call to get data from the API to then…
- … Populate iFrames to a div in our project
Before getting started in trying to build the AJAX call, you should first request an API key. The YouTube API Overview gives you step-by-step instructions on how to walk through getting started. You will need a Google account.
It took me forever to figure out how to breakdown the query URL, but once I was able to figure out how to structure that, I was well on my way to
Main URL: https://www.googleapis.com/youtube/v3/search?
- part=snippet: must always be set to “snipper”
- &q=: The
qparameter specifies the query term to search for.
- &type=: The
typeparameter restricts a search query to only retrieve a particular type of resource. The value is a comma-separated list of resource types. The default value is
video,channel,playlist.Acceptable values are:
- &order=: The
orderparameter specifies the method that will be used to order resources in the API response. The default value is
- &maxResults=: The
maxResultsparameter specifies the maximum number of items that should be returned in the result set. Acceptable values are
50, inclusive. The default value is
- &key=: API Key provided by Google/YouTube
I hope this helps break it down for you!
- Getting Started – YouTube