All language subtitles for 055 Fetching Data From The API.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,270 --> 00:00:02,560 All right, so we're going to get started on the JavaScript. 2 00:00:02,580 --> 00:00:07,440 But first, I want to look at the API we're using, which is the movie Dbag. 3 00:00:07,800 --> 00:00:14,040 So you need to actually sign up because you do need an API key when you make your requests. 4 00:00:14,220 --> 00:00:16,140 So you can see I'm already logged in here. 5 00:00:16,530 --> 00:00:22,010 And if you go to more and then API, you'll see this documentation. 6 00:00:22,020 --> 00:00:26,270 And if we look at discover examples, it gives you some endpoints that you can hit. 7 00:00:26,280 --> 00:00:33,060 So discover movie you can sort by, you know, release date or get a certain release date range you 8 00:00:33,060 --> 00:00:35,360 can sort by popularity and so on. 9 00:00:35,790 --> 00:00:42,180 But what we need to do is back in this API overview, this link right here, developers dot the movie 10 00:00:42,180 --> 00:00:43,500 dbag. 11 00:00:43,500 --> 00:00:49,340 If you click on that, you'll see a page like this and it says to register for an API key, click the 12 00:00:49,350 --> 00:00:49,650 click. 13 00:00:49,650 --> 00:00:53,490 This link here, you can see I already have an API key. 14 00:00:53,910 --> 00:00:58,800 So for me it says, if you'd like to edit the details of your app, click here. 15 00:00:58,800 --> 00:01:01,530 You should have an option to create a new app. 16 00:01:01,950 --> 00:01:04,920 And if I click here, you'll see I just called my movie app. 17 00:01:04,920 --> 00:01:10,170 I used localhost for the URL and it's going to ask you, you know, why you want this API? 18 00:01:10,170 --> 00:01:11,640 What do you plan on doing with this? 19 00:01:12,390 --> 00:01:20,250 And you can just say something like, you know, I'm creating a non production app using this API or 20 00:01:20,250 --> 00:01:21,050 something like that. 21 00:01:22,170 --> 00:01:26,070 So once you get that API key, you'll be able to make requests. 22 00:01:26,610 --> 00:01:31,890 Now, in the JavaScript here, I want to have a couple constants. 23 00:01:31,890 --> 00:01:38,380 One is going to be the API underscore you URL and that's going to be yes. 24 00:01:39,000 --> 00:01:50,310 And then it's API as a subdomain dot the movie dbag and then slash three because that's the version 25 00:01:50,310 --> 00:01:51,270 of the API. 26 00:01:51,810 --> 00:01:58,800 And then if we look at the go back to this page here, discover examples, it's going to be slash, 27 00:01:58,800 --> 00:02:02,190 discover slash movie and I want to sort by popularity. 28 00:02:02,190 --> 00:02:04,260 So I'm going to use this endpoint right here. 29 00:02:04,740 --> 00:02:09,060 So paste that and it's going to sort by popularity which is going to be descending. 30 00:02:09,630 --> 00:02:13,080 And then in addition to that, let's put an amp up here. 31 00:02:13,560 --> 00:02:22,680 We need our API underscore key and I'm going to set that equal to my key, which is right here. 32 00:02:24,660 --> 00:02:26,970 And I'll just I mean, you guys can use my key. 33 00:02:26,970 --> 00:02:29,280 I'm not sure what the rate limiting is or anything. 34 00:02:29,280 --> 00:02:33,810 You probably want to create your own, but if you really, really don't want to, I'll leave this key 35 00:02:33,810 --> 00:02:37,470 in the in the repository. 36 00:02:38,220 --> 00:02:39,300 So I'm going to paste that in. 37 00:02:39,300 --> 00:02:41,280 And this gives you a ton of results. 38 00:02:41,280 --> 00:02:44,580 And you can you can you can create pagination if you want. 39 00:02:44,580 --> 00:02:45,720 I'm not going to get into that. 40 00:02:45,720 --> 00:02:51,930 So I'm just going to do ampersand page equals one, which gives me, I believe the first like thirty 41 00:02:51,930 --> 00:02:53,070 results or something. 42 00:02:54,630 --> 00:02:57,000 And we can actually see what this gives us. 43 00:02:57,000 --> 00:03:07,230 If I grab that and go into chrome, you'll see it gives me an object with the page, the total results, 44 00:03:07,230 --> 00:03:10,440 the total pages and then a results array. 45 00:03:10,440 --> 00:03:17,610 That's where all the movie data is and has like the popularity, the vote count, the poster path. 46 00:03:17,610 --> 00:03:18,930 Here is the image. 47 00:03:18,930 --> 00:03:23,130 Notice there's no path, it's just slash and then an image file. 48 00:03:23,130 --> 00:03:25,410 So we need to get the image path for that. 49 00:03:25,450 --> 00:03:26,850 I'll show you how to do that in a second. 50 00:03:27,210 --> 00:03:34,650 We get the idea if it's Adults', the title description, so you can use all this data in your application. 51 00:03:34,800 --> 00:03:37,920 We're only using a small portion of it now. 52 00:03:37,920 --> 00:03:40,800 As far as the image goes, we have this poster path. 53 00:03:40,800 --> 00:03:44,220 But again, there's no there's no Eurail here. 54 00:03:45,210 --> 00:03:46,500 So I have this page. 55 00:03:47,160 --> 00:03:54,600 This is from the documentation we actually need to use something like this before the image names. 56 00:03:54,600 --> 00:04:01,620 So what I'm going to do is grab this, not the actual image here, the JPEG, but just grab that URL 57 00:04:01,620 --> 00:04:07,830 and let's say const image underscore path and I'm going to set it to that. 58 00:04:08,010 --> 00:04:10,770 And this last one is the width is the size. 59 00:04:11,160 --> 00:04:17,380 I'm going to use twelve eighty here instead of five hundred, but that's going to go before the image. 60 00:04:17,380 --> 00:04:22,800 And we actually don't want the slash because if we look at the response here for poster path it already 61 00:04:22,800 --> 00:04:24,330 has the slash in front of it. 62 00:04:24,330 --> 00:04:26,190 So don't add the slash here. 63 00:04:27,270 --> 00:04:30,630 And then we also want a search end point. 64 00:04:30,870 --> 00:04:41,190 So I'm going to copy this and let's call this search you URL and it's going to be the same route you 65 00:04:41,190 --> 00:04:41,940 earlier. 66 00:04:41,940 --> 00:04:50,670 But instead of discover we're going to use search, search and then slash movie. 67 00:04:51,300 --> 00:04:52,830 We don't want the by. 68 00:04:55,110 --> 00:04:58,470 What I do want though, what I do want is my API key. 69 00:04:58,470 --> 00:04:59,310 So let's say. 70 00:05:01,060 --> 00:05:05,440 Do API underscore key equals and. 71 00:05:08,200 --> 00:05:18,620 That in there and then the last thing we'll say ampersand, we want a query, so it's a query equals 72 00:05:18,620 --> 00:05:25,520 and what I'll do is just open a single double quote because I want to be able to concatenate a search 73 00:05:25,520 --> 00:05:28,490 term from our search box into here. 74 00:05:29,150 --> 00:05:29,570 All right. 75 00:05:29,570 --> 00:05:34,640 Because basically what we're doing is setting the, you know, the most popular movies on the on the 76 00:05:34,640 --> 00:05:36,530 landing page when we first get there. 77 00:05:36,540 --> 00:05:41,870 But if we use the search box, we're going to use this end point and we're going to add a query into 78 00:05:41,870 --> 00:05:42,270 here. 79 00:05:42,530 --> 00:05:49,010 So just put one double quote here and surround both and, you know, surround this in single quotes. 80 00:05:49,850 --> 00:05:50,240 All right. 81 00:05:50,250 --> 00:05:55,670 So now that we have that done, I just want to see if we can make a request. 82 00:05:55,670 --> 00:05:59,630 And then in the next video, we'll do the DOM stuff, you know, adding it to the page. 83 00:06:00,080 --> 00:06:01,630 So let's create a function. 84 00:06:01,640 --> 00:06:03,190 I'm going to use a sink away. 85 00:06:03,210 --> 00:06:13,370 So it's going to be an async function called get movies and it's going to take in a neutral and let's 86 00:06:13,370 --> 00:06:15,080 say const response. 87 00:06:15,080 --> 00:06:21,710 Araz, we want to await because remember, Fach returns a promise so you don't have to use a sink away, 88 00:06:21,710 --> 00:06:24,290 but then you'd have to do, you know, the dot then and stuff. 89 00:06:24,740 --> 00:06:28,360 So we're going to say, wait, fetch, pass in are you Earl? 90 00:06:29,570 --> 00:06:32,420 And then that will return a promise. 91 00:06:32,420 --> 00:06:35,990 But it's not going to give us the format of JSON just yet. 92 00:06:35,990 --> 00:06:44,240 We want to create another variable called data and we want to await for a resident, Jason, that will 93 00:06:44,240 --> 00:06:45,570 give us the actual data. 94 00:06:45,590 --> 00:06:50,990 So now let's consider log data and remember the response in the browser. 95 00:06:50,990 --> 00:06:53,580 It had a results, right? 96 00:06:53,660 --> 00:06:55,180 Had a results array. 97 00:06:55,670 --> 00:07:06,170 So I want to just look at that and then I'll go up here and let's say get initial movies and we're going 98 00:07:06,170 --> 00:07:11,400 to call, get movies and pass in our API URL. 99 00:07:11,900 --> 00:07:13,220 So I'm going to save this. 100 00:07:13,220 --> 00:07:20,720 And it's we can actually make this smaller now and it's minimized that. 101 00:07:21,260 --> 00:07:29,750 OK, so I just want to open up my console here and you can see we have an array of 20 objects and we 102 00:07:29,750 --> 00:07:32,150 have access to all this data here. 103 00:07:32,810 --> 00:07:33,200 All right. 104 00:07:33,200 --> 00:07:35,580 So we know that we can actually get the data. 105 00:07:35,840 --> 00:07:37,780 Now, let's go ahead and do the search. 106 00:07:37,790 --> 00:07:39,690 I'm not doing anything with the DOM just yet. 107 00:07:39,710 --> 00:07:40,880 We'll do that in the next video. 108 00:07:40,880 --> 00:07:46,390 But let's have an event listener on on the form. 109 00:07:46,400 --> 00:07:49,560 So what we do have to bring that in to do that. 110 00:07:49,580 --> 00:07:53,810 So I'm actually going to go under these constants, though. 111 00:07:54,470 --> 00:08:03,860 So let's say const form and say document dot get element by D and I believe I have an idea form. 112 00:08:04,130 --> 00:08:05,320 You still check that. 113 00:08:06,590 --> 00:08:07,910 So up in the header. 114 00:08:09,170 --> 00:08:09,530 Yeah. 115 00:08:09,530 --> 00:08:10,520 Idea form. 116 00:08:11,270 --> 00:08:17,630 All right, so bring that in and then down here, let's say form dot add event listener, we're going 117 00:08:17,630 --> 00:08:23,540 to listen for a submit and put a function here with our event object. 118 00:08:23,540 --> 00:08:35,370 And since it's a submit we need to call e dot prevent default so that it doesn't actually, you know, 119 00:08:35,390 --> 00:08:44,240 submit to the page and then let's create a variable called search term and set that to search, which 120 00:08:44,240 --> 00:08:48,800 we have to bring in as well, which is the the input. 121 00:08:48,800 --> 00:08:51,920 So we'll say const search. 122 00:08:53,510 --> 00:08:57,020 And I think I gave that an idea of search. 123 00:09:00,020 --> 00:09:04,280 OK, and then we want the value of that, because, remember, that's an input, so we want to get that 124 00:09:04,280 --> 00:09:16,400 value, put it in a variable and let's check to see if search term exists and also if search term is 125 00:09:16,400 --> 00:09:18,230 not equal to anything. 126 00:09:18,860 --> 00:09:19,360 All right. 127 00:09:19,370 --> 00:09:23,660 So then we'll call get movies, which we have above. 128 00:09:24,110 --> 00:09:32,120 Now we need a neutral this is where the search API or search you outcomes and actually let's call it 129 00:09:32,120 --> 00:09:35,810 search API. 130 00:09:37,550 --> 00:09:37,950 All right. 131 00:09:37,970 --> 00:09:42,100 And what we want to do is take the whatever we type in is going to get put in. 132 00:09:42,140 --> 00:09:45,320 We want to concatenate that on to our search API. 133 00:09:45,320 --> 00:09:51,830 So get movies, search API and then we're going to add on to that whatever the search term is. 134 00:09:52,800 --> 00:09:58,100 OK, so that will give us a response and then we'll just clear the search dot value. 135 00:09:58,100 --> 00:10:03,240 So we'll set search value equal to nothing and then we'll just have an else. 136 00:10:03,260 --> 00:10:07,900 So if we submit without having anything in there, I'll just reload the page. 137 00:10:07,910 --> 00:10:16,070 So window dot location, window, dot location, dot reload. 138 00:10:17,690 --> 00:10:18,050 All right. 139 00:10:18,060 --> 00:10:24,080 So what should happen now is when I search something here and submit it, you call, get movies. 140 00:10:24,440 --> 00:10:30,200 It should take the search API with the search term and give us those results. 141 00:10:30,380 --> 00:10:34,940 So let's just say, I don't know. 142 00:10:34,970 --> 00:10:36,370 I don't even know what to put here. 143 00:10:37,250 --> 00:10:38,300 What was some of the movies? 144 00:10:38,300 --> 00:10:39,740 We'll just say the word hard. 145 00:10:41,090 --> 00:10:41,480 All right. 146 00:10:41,480 --> 00:10:42,850 So we get a result here. 147 00:10:42,860 --> 00:10:43,880 Let's take a look. 148 00:10:43,880 --> 00:10:45,920 I just I want to check out the titles. 149 00:10:47,420 --> 00:10:48,890 So title Hard Kill. 150 00:10:50,340 --> 00:10:56,480 Look at this one here titled Die Hard Title Hard Target. 151 00:10:56,480 --> 00:10:56,750 All right. 152 00:10:56,750 --> 00:10:58,880 So we can see that the search is actually working. 153 00:10:59,810 --> 00:11:03,500 Now, we have the you know, the the HDP part of it done well. 154 00:11:03,500 --> 00:11:05,660 We're making requests are getting a response. 155 00:11:05,990 --> 00:11:12,260 So in the next video, we want to take this this functionality here and take this data and put it into 156 00:11:12,260 --> 00:11:14,630 the dorm so that it shows here. 157 00:11:14,960 --> 00:11:15,350 All right. 158 00:11:15,350 --> 00:11:16,490 So we'll do that next. 14829

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.