What is an API and how does it work? (In plain English)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey cuckoo let me ask you a question how do apps let you create an account and login with your Facebook or Google credentials here's another one how does your favorite weather app get today's weather forecast the answer to both of these questions they talk to other systems to get the data or to verify your credentials and the way that these two systems talk to each other is do something called an API or application programming interface an API simply states the rules for the communication to happen for example if you're applying for a passport you can't just go to the printing facilities and make yourself a passport there's a certain procedure that you have to follow you fill out the forms you take a photo you take these documents to a passport office and you talk to the lady and you hand in your documents you pay the fee and then you wait you have no idea what's happening behind the scenes once you hand in your documents the system took your inputs it's working in the back and when it's ready it'll produce your passport and give it to you this is exactly like how an API works the passport production process is the system that we want to communicate with we can't access the internals of the system we can only talk to the API layer which in this case is the lady at the counter at the passport office this is known as an endpoint which just means that she's a point of contact for us to submit our inputs with each endpoint there is a protocol about what inputs are required and what result you'll get in return if you don't supply the correct inputs then your requests will get rejected normally you'll also have to supply an API key with your request which is just a unique ID to identify your app this way the system has a record of who is accessing its endpoints now imagine that different systems will each have their own API with different endpoints and different protocols for each endpoint about what inputs are required your app can communicate and interact with all of these different systems through their respective api's luckily all api's will have some sort of documentation describing how to communicate with the endpoints and some systems won't have an API so you won't be able to talk to that system at all now let's see a more concrete example of working with an API oh yeah one quick thing today's video is sponsored by Atlanta ticket dotnet atlanticnet provides great VPS hosting and they are offering a free one gig virtual server with SSDs free block storage and free snapshots for an entire year in addition to that get $25 and free credits to use on any other services they offer try Atlanta net to develop test or launch your next project ease of use is something that I like as it frees up my mind to focus on coding I also like that they have round-the-clock phone support so if I happen to get stuck I can contact them easily so visit Atlantic dotnet slash code with Chris and enter the code Chris to get your $25 or free credit these guys are great give them a try and don't forget to use the coupon code Chris to get twenty five dollars in free credit that's an exclusive offer just for you guys now let's go through an example with an actual API this is News API where you can get the top headlines and news articles from a variety of different sources and this is an API that we actually work with inside of my courses now let's take a look at the endpoints that are available through News API so this one gives you all articles about Bitcoin in the last month sorted by the most recent first this URL is the endpoint and it gives you everything these are the inputs these parameters here so they're querying for Bitcoin right and they you can supply a date range and then you can also supply a sort what field you want to sort by so they want to sort by publish date and finally the last parameter that you have to input is an API key now this is actually my API key because I am logged in and so if I hit this endpoint right here and pass in these inputs they would know that I did this and they have a record of that and they can identify who is accessing their API before I actually hit this API endpoint let's take a look at another endpoint now this one you can see is a little different and it gives the top headlines so I guess it's the top news for today and here they're specifying different inputs they're putting in the country category just business and then again you have to supply your API key to access here they're using that same endpoint from our first example that's called everything and this applying a query called Apple from - this is a date range sort by popularity this time so let's try one of these API calls so all I have to do is just put it into my browser like that and so I'm hitting this news API dot-org v2 everything endpoint and I'm passing in these inputs and I'm also passing in my API key so when I hit enter I make that request to that endpoint and I get that these results according to the parameters that I've specified and this data format is called JSON which we'll go through in the next video next week but it's in the data format that I can parse and process and I can extract this information to use inside my app you can see each of these articles I can it's surrounded by these brackets here I won't get too much into it but each of them has well defined fields called author title description URL URL - image publish that the actual content and so it makes it very easy to grab each piece of information for each article and then format it inside my app and display it inside a scrollable list or something so now you understand what an API is well what's an SDK SDK stands for software development kit these are usually bits of code that will make it easier for you to work with an API so some systems will have an API and offer an SDK you can download and use in your project which will make it easier for you to work with that particular API there are thousands of api's out there and you can browse through them through API directories like this one at programmable web I actually think this is one of the largest API directories so if there's a particular API that you want to see a demo of please leave a comment below and I'll take a look at it and if you've enjoyed this video please give it a thumbs up and subscribe to the channel if you haven't already I really appreciate you and I'll see you next time
Info
Channel: CodeWithChris
Views: 185,568
Rating: 4.9379845 out of 5
Keywords: what is an api, what is an api and how does it work, what is api, application programming interface, api key, api call, api endpoint, api, apis, coding, programming, rest api, api integration, api tutorial, api tutorial for beginners, what is an api key, what is an api call, what is an api gateway
Id: Yzx7ihtCGBs
Channel Id: undefined
Length: 7min 11sec (431 seconds)
Published: Tue Jan 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.