What the #$%*@ is an API?
Well in this video we're going to be looking at what they are. what they're used for and we'll also take a look at a real-world example
Hey what's up guys welcome to CertBros. If you're new here this channel uploads regular IT training
videos just like this one. So if you like what you see here today don't forget to smash that
like button and consider subscribing so you don't miss out on any new videos
OK so API stands for Application Programming Interface which probably doesn't mean anything
to you right now, but by the end of this video you will know exactly what this means
let's imagine we have an application. This application has taken us years of development
and millions of pounds to build. If we want this application to be a worldwide success
we probably want the ability to integrate with other popular applications and services, right?
Well that leaves us with a bit of a problem. Imagine trying to build custom integrations with the
thousands of third-party apps that are available today. It just wouldn't be feasible. This is where
APIs come in. We can build an API onto our application. The API is essentially a doorway
into our application. Now using this doorway other third-party applications can get access to all of
the data and the features we built without us needing to provide any custom code whatsoever
this is how it works. Let's say this custom app wants to access some of the data or the features
that we have built. It will send an API request. API requests are sent in the form of a simple
http message. In this example we're using a get message to request information
but there are other http methods that we could use. For example the most popular methods are
Post Get Put Patch and Delete these methods correspond with something called crud operations
crud stands for create read update and delete. The Post method
creates something on the web application. Get requests read information from the application
Put updates information on the application. Patch also updates information on the application the
difference is put will replace the information and patch will modify the information. And of course
Delete will delete the information. Once the API request has been sent the application will send
back a response . The response will be sent back to the custom app usually in a JSON or XML format
So that was a very basic high level overview of what APIs are and how they work
To get a better understanding of this let's use something a bit more relatable. Instead
of this generically named app here on the right , this is now a weather app with a huge network
of weather stations set up all around the world. And our custom app is now a mobile app
now for most of us building a worldwide network of weather stations and compiling all of that
information is nearly impossible, but this is the beauty of APIs. Anyone can build a mobile app
and then use APIs to request the data from an already existing weather application
Let's see how this could work. Our mobile app sends an API Get request to the weather application. Here
is an example of an API request using the open weather map API. As you can see it's a simple URL
this URL contains some fields. One field is where the app would enter the city and the other field
is something called an API key. An API key is usually required so the application can keep
track of the number of requests being sent and also make sure that you're not spamming them
Once the application receives this request it will respond with the requested data. Here is a
small snippet of one of the responses. This is in JSON format which is something we'll
look at closer in another video. We can see different names and values here. We get the
actual temp what the temp feels like humidity etc. Now we have this we can program our mobile app to
take this information and display it in a nice pretty user interface. And I'm sure you can guess
yes this is a British temperature reading. Hopefully that's starting to make sense. Let's go
through another example but this time a little bit more hands-on. Instead of the weather, the app we
want to connect to this time is something i'm sure you're all familiar with YouTube
and this time we're going to connect not from our mobile app but from our computer
so this is my computer. Most applications that have an API will also have documentation
explaining how it works the available features etc. and youtube is no different. If you go to
developers.google.com /youtube/v3
this is what you will see. This site tells us all you need to know about youtube APIs
if we click on guides at the top we can see all of the how-to guides. The first one we see is the
overview. This tells us exactly what we need to do to get started. We need a google account to access
the google API console. We also need to start a project to obtain some credentials. Now this
isn't a tutorial on youtube API specifically so if you're going to try this yourself have a read
through this guide and it should take you through the steps you need. The next page is reference
this is where we can find all of the available API information that youtube has made available to us
to show you an example i'm going to choose the channel resource on the left. I'm going to select
list because i want to request some information about a youtube channel
once we click on list we're going to see a huge amount of very useful information. We can see some
common use cases the http request itself and also all of the available parameters that we can use
over here on the right we have a very handy tool this tool allows us to try the api out
right here in the browser. It's worth noting that not all API documentation is made equal
Google provides incredibly helpful documentation and tools however other services may not provide
you with this amount of handholding. So this is a really great place to start.
So we could use this built-in tool but for this example i'm going to open an
application called postman. Postman is an API client that allows us to send API requests
and receive responses in a nice easy to understand format. As you can see i have already gone ahead
and entered our API request here. The first part of the API request is the channel resource
then we have some parameters. A benefit of using a program like postman is it can
display the parameters in a nice easy to read format. The first one is part=statistics
this tells the API that we are looking for statistical information about a YouTube
channel. The next parameter is ID. This states the channel id we want to request the information for
And the final parameter is the key. The key is the API key linked to my google account
this way they can limit the number of requests being sent from one individual. Otherwise their
systems could potentially get spammed and overwhelmed. I've censored the key because
it's unique to me if you try this yourself you will be asked to generate your own
key. Ok let's go ahead and send this API request off to youtube. Almost straight away we receive a
response back from the YouTune API. The response we get back is in the standardized JSON format
If we look closely we can see the channel id we selected which by the way is the CertBros YouTube
channel. We can also see the statistics that we requested. The view count which as of today is 4274066
The subscriber count which is 65500
and the video count which is 45. So now we have this data what can we do
with it? Well we could write an application that takes this data and displays it in some way. Now
this is way beyond my capabilities so i'm going to use someone else's application as an example
i'll open my browser again and i'll click onto the next tab. This is a site you may have seen before
Socialblade provides statistics on various social media platforms. Here we can see the CertBros
youtube channel. We can see the channel views the subscriber count and the number of videos uploaded
all of the information that we just got from our API request
of course Socialblade takes this one step further and shows detailed statistics from various sources
this is the beauty of APIs. Any one of you watching this with the right know-how could build
an application just like Socialblade without the need to build any custom integration with YouTube
and this isn't just YouTube and Google
you'd be hard hard-pressed to find a popular application these days
that doesn't offer API access. With APIs becoming so popular the possibilities really are endless
You should now have a solid understanding of what APIs are, how they work and the benefits of using
them. If you liked this video don't forget to give it a thumbs up, leave a comment and subscribe. The
support from you guys really helps this channel grow. Other than that thank you for watching