WEBVTT 00:00.450 --> 00:01.560 Yo, what's up? 00:01.620 --> 00:04.680 Welcome to the Jango API course. 00:04.770 --> 00:07.980 Before we get started here, I want to make sure we have two things clear. 00:08.010 --> 00:13.470 The first one is, is that you should have some Django experience before you take this course. 00:14.010 --> 00:19.620 If you're a complete newbie to Django period, I would highly recommend going and checking out my Django 00:19.620 --> 00:25.830 three course or some sort of equivalent intro to Django thing so that you least have a basic understanding. 00:26.070 --> 00:28.830 Now, assuming that we've got that out of the way. 00:29.160 --> 00:31.830 The next question is, is this the right course for you? 00:31.890 --> 00:34.980 Why do you want to create an API with Django? 00:35.280 --> 00:40.740 Well, what I'd like to do here in this video is talk about what API is are and why they're important. 00:40.770 --> 00:45.330 And I think by the end of this, you'll be able to answer the question of do I want to build an API? 00:45.510 --> 00:46.260 I suspect you do. 00:46.260 --> 00:49.650 Said you signed up for the course, but let's make sure we're all on the same page. 00:50.370 --> 00:51.450 Now, what is an API? 00:51.540 --> 00:54.210 It stands for application programming interface. 00:54.900 --> 00:55.770 That doesn't matter. 00:55.830 --> 00:57.990 No one cares what the technical definition is. 00:58.920 --> 01:04.140 In the end, there's lots of different API is when we use this word, like, for example, when you're 01:04.140 --> 01:09.930 developing a Mac or IOW applications, there's an API to connect with the operating system. 01:10.620 --> 01:13.140 But that's not the type of API that we're talking about. 01:13.560 --> 01:21.060 We're talking about a Web API, essentially a way for two computers to talk to each other. 01:21.090 --> 01:23.640 So this gets into why APIs are so important. 01:24.000 --> 01:28.810 So, for example, lots of social media sites like Twitter and Facebook have API. 01:29.400 --> 01:34.320 And the reason that they have them is, for example, let's say I wanted to make a Web site that goes 01:34.320 --> 01:41.490 and gets the top trending tweets from Twitter and it displays them on my own Web site in some sort of 01:41.490 --> 01:43.080 cool, fashionable way. 01:43.110 --> 01:43.440 Right. 01:43.860 --> 01:50.250 Well, I could make a program that goes to Twitter, dot com clicks on the trending tab and then, you 01:50.250 --> 01:52.020 know, goes and copy's K, number one. 01:52.020 --> 01:53.190 Number two, number three. 01:53.580 --> 01:59.280 And, you know, I can even, you know, look at the actual H.T. AML code behind Twitter dot com. 01:59.280 --> 02:02.520 And I can, you know, highlight specifically the different things that are there. 02:03.060 --> 02:05.220 But this is really inefficient. 02:05.280 --> 02:07.200 This is called web scraping, by the way. 02:07.560 --> 02:12.300 And the reason that it's very inefficient is because Twitter could change the way that their home page, 02:12.570 --> 02:17.550 home page looks at any time, like maybe they'd move the trending tab to the right size of news. 02:17.550 --> 02:23.400 And maybe, you know, the particular ideas that they use for these A.T.M. tags is going to change. 02:23.490 --> 02:25.650 Anything could happen here like Twitter. 02:25.650 --> 02:29.480 Dot com is a great way for me as a human to interface with Twitter. 02:29.520 --> 02:35.070 But if I'm trying to build a website or an app that gets information from Twitter, well, it's really 02:35.070 --> 02:35.670 terrible. 02:36.450 --> 02:43.890 So what we have then is a Twitter API and if we go ahead and search the Twitter API. 02:45.280 --> 02:51.470 There is tons of documentation showing how we can go and grit, get different tweets from from places, 02:51.470 --> 02:51.650 right. 02:51.660 --> 02:55.940 And it says, OK, if you go ahead and, you know, want to get the timeline for a particular user, 02:55.940 --> 02:56.930 you can go here. 02:57.530 --> 03:01.160 This is the you are all that you should be going to and this is how it's going to look when it comes 03:01.160 --> 03:01.450 back. 03:01.460 --> 03:04.750 Like this is information that a computer can rely on. 03:04.760 --> 03:10.130 Basically Twitter saying I'm going to output my information like this and I'm always going to output 03:10.130 --> 03:14.360 it like this so that you can make sure that you can consume it the same way. 03:14.570 --> 03:19.730 So if this still isn't exactly making sense, let me go to a lot simpler example. 03:19.790 --> 03:21.260 So let's go to my Web site. 03:21.980 --> 03:23.730 Zappy code dot com. 03:24.010 --> 03:24.170 OK. 03:24.830 --> 03:30.800 So here on Zappy Code, I have courses where if you remember on my Web site, you get access to these 03:30.800 --> 03:31.310 courses. 03:31.310 --> 03:33.230 And here you can see there's three right now. 03:33.590 --> 03:37.340 And, you know, someone could go to zappy code dot com slash courses and go look at these. 03:37.670 --> 03:43.430 But what if I wanted to build, again, some Web site or app that always listed out the different courses 03:43.460 --> 03:44.840 that zappy code offers? 03:45.380 --> 03:51.500 Well, if I tried to get just the raw H-E email here, I'm probably going to be changing the design 03:51.500 --> 03:52.700 of this Web site at some point. 03:52.700 --> 03:55.430 Like, as you can tell, it's not the greatest thing in the world. 03:55.430 --> 03:59.870 I try and make it fun, but, you know, maybe someday I'll say all this purple text, you know, isn't 03:59.870 --> 04:00.290 worth it. 04:01.040 --> 04:03.320 But I have an API. 04:03.350 --> 04:11.350 So if you go to zappy code dot com slash API slash courses, OK. 04:12.260 --> 04:20.090 You then get an API showing exactly what all the courses are, but in this very machine readable format. 04:20.300 --> 04:22.130 Now what is this particular format? 04:22.160 --> 04:24.410 The one that you see here is called Jason. 04:24.830 --> 04:26.930 So there's lots of different ways to display data. 04:26.960 --> 04:33.950 It could be X Amelle CSF vs Jason, but pretty much at this point, the most popular one that you see 04:33.980 --> 04:35.340 almost everywhere is Jason. 04:35.360 --> 04:36.740 It's considered the standard. 04:37.160 --> 04:41.720 So if you go ahead and just look at this, this is sort of like a pretty way to view the API. 04:41.750 --> 04:47.960 The real raw API is if you go ahead and change this, to say I want to get this in strict Jason, it 04:48.020 --> 04:53.030 looks like this just a big jumble of text, but it has all the right information there. 04:53.330 --> 04:55.550 Now, if we wanted to see this a little bit more pretty. 04:55.610 --> 04:58.760 Like, for example, how it automatically did it for us here. 04:59.300 --> 05:01.880 If we go ahead and open up a new tab, we can search for it. 05:01.960 --> 05:03.740 Jason Validator. 05:06.810 --> 05:12.210 Jason, is this whole spek that if you're going to send data back and forth with Jason, it has to adhere 05:12.210 --> 05:12.720 to the rules? 05:12.720 --> 05:18.690 So there's all these different formatters that will allow you to sort of check and say, hey, is my 05:18.690 --> 05:19.980 Jason accurate? 05:20.340 --> 05:26.220 So, for example, here, I can go ahead and select all this, Jason and I can paste it into here and 05:26.220 --> 05:28.950 say, hey, I want to make sure that this is valid. 05:28.950 --> 05:29.880 So I'm going to validate it. 05:29.910 --> 05:31.140 And it says, yes, it's valid. 05:31.170 --> 05:35.640 And a nice side benefit is most of these validators will sort of organize it for you. 05:35.640 --> 05:39.330 And you can see when I do it like this, it's like, oh, OK, there's three classes. 05:39.750 --> 05:44.550 You know, each of the classes has like a release date, an image that I could link to a title and a 05:44.550 --> 05:45.150 subtitle. 05:45.330 --> 05:45.960 That's really nice. 05:45.990 --> 05:52.680 So this API allows us to see essentially the same thing as this. 05:52.970 --> 05:55.440 I'm going to go to Zappy COCOM slash courses. 05:56.110 --> 05:59.610 OK, so this is sort of the human readable one. 05:59.760 --> 06:01.410 This is the computer readable one. 06:01.530 --> 06:07.080 So the reason that API is are important is they allow computers to be able to talk to each other in 06:07.080 --> 06:12.120 some sort of defined way that when someone puts out an API, they're essentially saying, I promise, 06:12.120 --> 06:13.920 I'm always going to deliver the data like this. 06:13.920 --> 06:20.070 For example, with my API here, I'm always going to provide the I.D., the release date, the image, 06:20.070 --> 06:20.700 the title. 06:20.730 --> 06:25.350 I'm not going to change this to capital title, for instance, like you can bank on the way that this 06:25.350 --> 06:26.010 is going to come out. 06:26.100 --> 06:29.850 Now, there may be new courses, there may be a new course that has an idea of seven. 06:30.420 --> 06:32.190 That is not not a jingo three course. 06:32.220 --> 06:34.440 Maybe at that point it's a jingle for course. 06:35.040 --> 06:36.480 Who knows what's coming out in the future. 06:36.510 --> 06:43.590 But I know that there's going to be an array of courses that has this particular format to get the different 06:43.590 --> 06:44.910 pieces of information. 06:46.170 --> 06:53.010 So with that in place, hopefully you've got a good grasp of, you know, hey, maybe I do want to build 06:53.010 --> 06:58.860 an API is to just kind of talk about the reasons why one could be, for example, you want to build 06:58.860 --> 06:59.430 a mobile app. 06:59.460 --> 07:06.270 If I wanted to create a mobile app of Zappy COCOM, I would have to build out Nolde whole API that lists 07:06.270 --> 07:06.990 out the courses. 07:07.040 --> 07:12.330 Banaz, not just the courses it be even the lectures here that are all listed out. 07:12.330 --> 07:14.730 I need would need to be able to get that information. 07:14.760 --> 07:18.500 There's like a whole, you know, log in and sign up system months AP code. 07:18.500 --> 07:20.060 I would have to integrate all of that. 07:20.070 --> 07:24.930 There's a lot of steps that go into play to building that, but an API is the way to do that. 07:24.960 --> 07:30.120 Another one is maybe you just want to broadcast some sort of information, like a really common one 07:30.120 --> 07:31.560 is you'll see whether API. 07:31.620 --> 07:36.510 So if you want to have an app that takes advantage of the user's location and says, hey, you know, 07:36.510 --> 07:40.620 this is what the weather's going to be for you today, you could use a weather API to do that. 07:40.620 --> 07:42.780 And there's tons of Web sites that will offer that for you. 07:42.900 --> 07:49.680 So if you think you're ready to go build an API for yourself, let's go ahead and get started right 07:49.830 --> 07:50.310 now.