1
00:00:00,270 --> 00:00:00,910
All right.

2
00:00:00,900 --> 00:00:01,950
Welcome back.

3
00:00:01,950 --> 00:00:08,160
So in this video we're going to talk about making or starting an application an express application

4
00:00:08,460 --> 00:00:10,000
that uses an API.

5
00:00:10,260 --> 00:00:11,430
So we're going to use a different API.

6
00:00:11,430 --> 00:00:12,980
We haven't really seen yet.

7
00:00:13,290 --> 00:00:14,830
It contains movie data.

8
00:00:14,970 --> 00:00:22,170
If you're familiar with familiar with IMT the Internet Movie Database this is a version of the data

9
00:00:22,170 --> 00:00:25,910
contained in that API called the Open Movie Database.

10
00:00:25,950 --> 00:00:27,150
Oh MTV.

11
00:00:27,270 --> 00:00:32,240
So MTV doesn't actually provide an API that we could use.

12
00:00:32,250 --> 00:00:36,310
So someone went through and basically created this API.

13
00:00:36,370 --> 00:00:44,400
Oh MBB open movie database that's free and contains all the movie information off of I am D-B.

14
00:00:44,580 --> 00:00:51,450
So we're going to make a simple app basically has two views and express app one will be a search form

15
00:00:51,870 --> 00:00:59,670
and you can type in something like frozen or Harry Potter and then it will do a search on the API using

16
00:00:59,670 --> 00:01:06,630
your search term and then show you results page with a list of 10 movies set up to 10 movies at least

17
00:01:06,630 --> 00:01:09,070
that match your query.

18
00:01:09,120 --> 00:01:10,700
It's going to be very simple as it mentioned.

19
00:01:10,830 --> 00:01:12,210
We're not going to style it or anything.

20
00:01:12,210 --> 00:01:19,560
This is really about just showing you how to get going with an API and it's basically what we've already

21
00:01:19,560 --> 00:01:26,820
seen using that request module just like we did here but instead of making the request just in a in

22
00:01:26,830 --> 00:01:33,840
a empty J S file you'll put it inside of an express app like in a route for example.

23
00:01:34,260 --> 00:01:42,930
So let's start by making our basic express app going to make whip's make a new directory here and I'll

24
00:01:42,930 --> 00:01:51,960
just call this movie search app CD into that NPM and it

25
00:01:55,140 --> 00:01:57,660
sure that's our name version.

26
00:01:57,850 --> 00:01:59,450
How do app.

27
00:01:59,470 --> 00:02:03,910
J.S. everything else is fine.

28
00:02:04,440 --> 00:02:17,100
OK then we'll do our NPM install dash dash save and we want express we want SJS and we want to use request

29
00:02:17,670 --> 00:02:21,870
because we're going to be making a request just like that.

30
00:02:22,290 --> 00:02:23,750
Let that finish up.

31
00:02:24,480 --> 00:02:30,100
And while that's going let's talk about the way that this API is structured.

32
00:02:30,570 --> 00:02:37,360
So if we take a look on the documentation that you are at by the way it's just oh MDVIP com.

33
00:02:37,610 --> 00:02:43,830
We take a look at the documentation and scroll down you can see that there is a list of parameters that

34
00:02:43,830 --> 00:02:45,440
we can use.

35
00:02:45,570 --> 00:02:53,190
So there are two main ways we access this API by ID or title and by search.

36
00:02:53,790 --> 00:02:56,180
So this will make sense once I show you some examples.

37
00:02:56,190 --> 00:03:02,620
But the idea is that if you have a specific idea of a movie so every movie has an idea.

38
00:03:02,640 --> 00:03:08,460
So if I have the idea for Harry Potter and the Sorcerer's Stone the film then I can get all sorts of

39
00:03:08,460 --> 00:03:15,810
information about that one movie plot the rotten tomatoes data you know the year it's made the poster

40
00:03:15,840 --> 00:03:19,860
image a bunch of stuff but I can also search.

41
00:03:19,860 --> 00:03:24,420
So if I'm not sure of a title or if you know I just want to add search capability and I want to get

42
00:03:24,420 --> 00:03:26,090
multiple results.

43
00:03:26,130 --> 00:03:31,860
So to clarify this first one we talked about we'll give you one Russell only and a lot of detail.

44
00:03:31,950 --> 00:03:38,360
A lot of detail and information for one result but if you want to search and get 10 results and I can

45
00:03:38,360 --> 00:03:44,010
search for Harry Potter or Harry just Harry and get multiple results but I won't get a ton of information

46
00:03:44,760 --> 00:03:46,990
so I'll show you how that works.

47
00:03:47,160 --> 00:03:48,980
Let's start with search.

48
00:03:49,020 --> 00:03:53,110
Notice that the parameter S is required.

49
00:03:53,130 --> 00:03:55,360
So that's the only required thing.

50
00:03:55,500 --> 00:04:00,520
And the description is that it's a movie title to search for.

51
00:04:00,540 --> 00:04:01,530
Sure it's kind of confusing.

52
00:04:01,530 --> 00:04:05,910
But if we just make a request I'll show you what you are Lwin need to go to.

53
00:04:05,910 --> 00:04:07,840
So I'm going to just copy this URL.

54
00:04:07,900 --> 00:04:09,380
Or put up a new tab.

55
00:04:09,930 --> 00:04:16,020
And if you scroll up you can see send all data requests to OODB API dot com slash.

56
00:04:16,020 --> 00:04:23,130
Question mark so we'll do that slash question mark and then we're going to do a search so to search

57
00:04:23,130 --> 00:04:29,010
we need parameter as it's required and it should equal the movie title to search for.

58
00:04:29,460 --> 00:04:33,450
So as equals and let's do star.

59
00:04:33,510 --> 00:04:37,970
So we'll get Star Wars maybe Star Trek hit enter and that's it.

60
00:04:38,310 --> 00:04:46,090
And we get Jason 10 results Star Wars Episode Four Star Wars Episode 5 6 Apollo blah.

61
00:04:46,200 --> 00:04:48,790
Star Trek Star Trek Into Darkness.

62
00:04:48,870 --> 00:04:50,420
So we get 10 results there.

63
00:04:50,910 --> 00:04:59,340
So that is a search but we'll see what we can also do is then take one of these let's say the ID right

64
00:04:59,340 --> 00:05:08,640
here going to copy it and if we go back to the documentation you can also retrieve information by ID

65
00:05:08,640 --> 00:05:09,290
.

66
00:05:09,330 --> 00:05:13,250
So as you can see here we either need to use I or t.

67
00:05:13,770 --> 00:05:20,910
So I will search by an ID be id TIV a search by an exact title and it gives us 1 result.

68
00:05:21,210 --> 00:05:23,430
So I'll get more information.

69
00:05:23,490 --> 00:05:24,990
So let's do it by eye.

70
00:05:25,200 --> 00:05:27,410
So we can open up another tab.

71
00:05:27,510 --> 00:05:28,840
MTBE API.

72
00:05:29,430 --> 00:05:34,500
Question mark I equals that I am D-B ID.

73
00:05:35,070 --> 00:05:37,440
You can see I get more information.

74
00:05:37,680 --> 00:05:44,340
So not just the title and the year but the rating the runtime the genre director all sorts of stuff

75
00:05:45,360 --> 00:05:47,640
versus this search here.

76
00:05:47,670 --> 00:05:49,570
So we're going to work with this search.

77
00:05:49,650 --> 00:05:55,770
We're going to have an API we're going to have a form that user can enter a query like Star Wars or

78
00:05:55,770 --> 00:06:02,730
Harry Potter or whatever California and then we're going to take whatever the user types into that form

79
00:06:03,600 --> 00:06:04,710
and just put it right here.

80
00:06:04,740 --> 00:06:05,720
And you are.

81
00:06:06,030 --> 00:06:14,670
So as will equal California then we'll get this Jason back and then we'll parse it and then display

82
00:06:14,760 --> 00:06:15,410
the results.

83
00:06:15,450 --> 00:06:20,640
So the last thing I want to mention is some of these optional parameters some of these other things

84
00:06:20,640 --> 00:06:22,720
that we can work with.

85
00:06:22,860 --> 00:06:30,960
So here if we take a look at the BY id search the by id query we can also add in things like We want

86
00:06:30,990 --> 00:06:37,420
plot to be short or full or we want rotten tomatoes data.

87
00:06:37,470 --> 00:06:39,030
So let's try that.

88
00:06:39,030 --> 00:06:40,470
Let's do this here.

89
00:06:40,650 --> 00:06:43,750
Take a look at the plot here.

90
00:06:43,830 --> 00:06:55,250
Now if I add in with an ampersand that's how query strings are constructed and plot equals full.

91
00:06:56,190 --> 00:06:57,540
It's a little bit longer.

92
00:06:57,690 --> 00:07:04,750
I don't know if it's really that noticeable but it goes down to here versus if it's short it ends right

93
00:07:04,770 --> 00:07:06,720
here and Darth Vader.

94
00:07:07,410 --> 00:07:15,160
Likewise I can also add in tomatoes equals true which will give me rotten tomatoes data.

95
00:07:15,450 --> 00:07:19,230
So we get all this rotten tomatoes data here as well.

96
00:07:19,320 --> 00:07:21,280
So that's kind of fun.

97
00:07:21,600 --> 00:07:25,470
The key thing is that you can add in these parameters.

98
00:07:25,470 --> 00:07:27,010
This one is mandatory.

99
00:07:27,270 --> 00:07:31,530
And then other things but they all follow that key value pair like a normal query string that you've

100
00:07:31,530 --> 00:07:33,120
seen before.

101
00:07:33,120 --> 00:07:38,430
But the way that you know how to structure these calls is based off the documentation and I should have

102
00:07:38,430 --> 00:07:39,470
mentioned this earlier.

103
00:07:39,540 --> 00:07:46,740
They have a nice example here so you can do a search like if you want to figure out OK let's search

104
00:07:46,740 --> 00:07:55,530
for byte title movie that has Harry Potter in the title came out in 2000 13 not enough.

105
00:07:55,530 --> 00:08:00,060
Actually there was one we can figure off and do full.

106
00:08:00,420 --> 00:08:02,590
And I want Jaison.

107
00:08:03,600 --> 00:08:06,140
It gives you that you are ill that you could use.

108
00:08:06,900 --> 00:08:10,330
And it gives us a sample result.

109
00:08:10,830 --> 00:08:17,180
So you can play around with this and we can change it to SML and we get this X-amount hideous Actimel

110
00:08:17,210 --> 00:08:19,940
I don't like ex-MIL at all.

111
00:08:20,160 --> 00:08:22,880
So that's kind of nice to play around with it.

112
00:08:22,890 --> 00:08:23,980
OK.

113
00:08:24,060 --> 00:08:25,390
So let's send this video here.

114
00:08:25,410 --> 00:08:29,070
And then in the next one will actually get back to constructing the application.
