Transcript from the "APIs & fetch" Lesson
[00:00:41] They point to certain resources on the web. So for example this one points to, it's cut off, but it points to a JPEG file an image of a bluetick dog breed. I don't know that breed, but apparently it looks like that it's cute, I think, anyway, so images or, web pages or whatever we know URLs.
[00:02:11] In fact, that's where I got all of that information for that big long breeds array. And one of the things that we can do, APIs usually have a certain structure that the API developer. Or the company, or what have you that maintains the API will document and they'll tell you what the structure of their URLs is.
[00:02:29] But in the case of dog ceo, I can find data that I care about, like let's say a list of all of the types of hound breeds, by going to the URL, dog.ceo/api/breed/hound/list. And that is what's called often an end point of an API. Meaning a URL within the API which is a whole big set of different URLs, an endpoint is one of those URLs that gives me a particular usually it's called a resource.
[00:04:04] It's basically just a convention for how we can represent objects that are very similar to the objects we've been working with this whole time. So that we can kind of save that object as a piece of text that I can then send across the wire. And my browser knows how to read that, and parse it out and see that we've got an array in our message property that has seven different breed strings in it.
[00:04:32] So suffice it to say, that so far we've been working with data that we either hard coded, we wrote it ourselves in our program. Or maybe we got it as the output of some built in function, like document.queryselector or something like that. But sometimes we need data from elsewhere, on the web, and we can do that by accessing these URLs that are API endpoints.
[00:04:58] Cool, so [COUGH].
>> Could you do like a map or a filter from an array to filter it further or.
>> So, once we've got a resource from an API endpoint, once you've got a chunk of data, in this case, an object that looks like this. And we have this array in our message property, once we've got it into our program, we can do whatever we want with it.
[00:06:28] API is one of these very confusingly, one of these terms that's used to mean a lot of different things. Or we say it's overloaded, the same way that our plus operator is used to do a lot of different things, it's overloaded, so is the term API [LAUGH]. But in this case, the Fetch API is also something you might hear.