1 00:00:00,879 --> 00:00:03,379 Hello and welcome to the first section 2 00:00:03,379 --> 00:00:05,509 of this course. In this section we're 3 00:00:05,509 --> 00:00:06,709 gonna talk about getting started with 4 00:00:06,709 --> 00:00:09,530 API testing, and dive right in. Here we're 5 00:00:09,530 --> 00:00:11,200 going to learn a little bit about 6 00:00:11,200 --> 00:00:14,780 understanding web services and APIs. So 7 00:00:14,780 --> 00:00:16,489 you may have heard the term web services 8 00:00:16,489 --> 00:00:18,439 before, her talk about a service-oriented 9 00:00:18,439 --> 00:00:20,689 architecture, or maybe your company is 10 00:00:20,689 --> 00:00:22,880 even moving towards us, but what exactly 11 00:00:22,880 --> 00:00:26,269 is meant by this? It can be hard to pin 12 00:00:26,269 --> 00:00:28,849 down exactly what we mean, but for the 13 00:00:28,849 --> 00:00:30,710 purpose of this course we want to think 14 00:00:30,710 --> 00:00:32,509 about how we can test web services, and 15 00:00:32,509 --> 00:00:34,130 so we're going to think of them as being 16 00:00:34,130 --> 00:00:35,780 functions that we can access over the 17 00:00:35,780 --> 00:00:37,640 web. Now let's think about that 18 00:00:37,640 --> 00:00:39,650 definition for a minute, and think in 19 00:00:39,650 --> 00:00:41,270 particular about the implications that 20 00:00:41,270 --> 00:00:43,850 has for testing. And so to do that I want 21 00:00:43,850 --> 00:00:45,380 to take a step back into something that 22 00:00:45,380 --> 00:00:47,090 I learned in grade school when the 23 00:00:47,090 --> 00:00:48,860 concept of a mathematical function was 24 00:00:48,860 --> 00:00:50,990 introduced to me, and don't worry we're 25 00:00:50,990 --> 00:00:52,880 not gonna get into any deep math here or 26 00:00:52,880 --> 00:00:54,980 anything. But we can think about it in 27 00:00:54,980 --> 00:00:58,160 this way, a function takes in some input, 28 00:00:58,160 --> 00:01:00,950 it does something with those inputs and 29 00:01:00,950 --> 00:01:04,069 then it produces some kind of output. So 30 00:01:04,069 --> 00:01:06,500 when thinking of it in these terms, we 31 00:01:06,500 --> 00:01:08,210 can think of the web service as this 32 00:01:08,210 --> 00:01:11,000 little black box here in the middle. We 33 00:01:11,000 --> 00:01:13,490 give it some inputs, the web service 34 00:01:13,490 --> 00:01:16,070 takes those inputs and does something 35 00:01:16,070 --> 00:01:18,920 with them to produce outputs that we 36 00:01:18,920 --> 00:01:22,910 want, and so these inputs and outputs 37 00:01:22,910 --> 00:01:26,090 define something that we call an API. So 38 00:01:26,090 --> 00:01:28,100 we can think of an API as a definition 39 00:01:28,100 --> 00:01:29,780 of what commands the service will accept 40 00:01:29,780 --> 00:01:33,050 from us, the inputs, and what kinds of 41 00:01:33,050 --> 00:01:34,760 things it will produce for us, the 42 00:01:34,760 --> 00:01:37,909 outputs. So these of course are not the 43 00:01:37,909 --> 00:01:39,830 only kinds of inputs and outputs that 44 00:01:39,830 --> 00:01:41,000 you might have in a service, there could 45 00:01:41,000 --> 00:01:44,240 be a database behind the scenes, or some 46 00:01:44,240 --> 00:01:46,460 other code, or logging, or things like 47 00:01:46,460 --> 00:01:48,050 that that we don't have access to 48 00:01:48,050 --> 00:01:50,330 through the API, but in this course we're 49 00:01:50,330 --> 00:01:51,890 going to be focusing on what you can 50 00:01:51,890 --> 00:01:53,960 figure out about this black box here in 51 00:01:53,960 --> 00:01:57,170 the middle by using the API calls. So 52 00:01:57,170 --> 00:01:59,270 let's make this just a little more 53 00:01:59,270 --> 00:02:02,180 concrete, and we can see here that I've 54 00:02:02,180 --> 00:02:04,670 got a URL in Postman, and I've got 55 00:02:04,670 --> 00:02:05,299 something called 56 00:02:05,299 --> 00:02:08,389 GET. So we're going to get this URL, and 57 00:02:08,389 --> 00:02:10,490 let's just send that command. Now you can 58 00:02:10,490 --> 00:02:12,500 see that we've gotten back a whole bunch 59 00:02:12,500 --> 00:02:14,270 of stuff down here, 60 00:02:14,270 --> 00:02:15,800 and this is in something that's called 61 00:02:15,800 --> 00:02:18,680 the JSON format. So before we get into 62 00:02:18,680 --> 00:02:20,180 what JSON is, let's just talk for a 63 00:02:20,180 --> 00:02:23,270 minute about what we did here. So we have 64 00:02:23,270 --> 00:02:27,890 this URL which is an API call, so we're 65 00:02:27,890 --> 00:02:31,040 telling the API at GitHub.com that we 66 00:02:31,040 --> 00:02:34,550 want to get user 1. And we said we want 67 00:02:34,550 --> 00:02:38,390 to GET it, we send that URL to the GitHub 68 00:02:38,390 --> 00:02:41,300 API and we tell it that it's a GET call. 69 00:02:41,300 --> 00:02:43,700 GitHub will return us a whole bunch of 70 00:02:43,700 --> 00:02:47,930 information about user 1. And so you can 71 00:02:47,930 --> 00:02:49,820 see the power of doing something like 72 00:02:49,820 --> 00:02:50,810 this, it's very simple, it's very 73 00:02:50,810 --> 00:02:52,550 straightforward, it's a simple command 74 00:02:52,550 --> 00:02:54,740 that we can execute to give us back this 75 00:02:54,740 --> 00:02:57,290 information. And as I said before, this 76 00:02:57,290 --> 00:02:59,570 gets us back the information in a JSON 77 00:02:59,570 --> 00:03:03,170 format. And JSON is just a way of mapping 78 00:03:03,170 --> 00:03:06,020 keys to values, so it's a dictionary, map, 79 00:03:06,020 --> 00:03:09,710 whatever term you prefer, but it takes a 80 00:03:09,710 --> 00:03:12,230 key like login and maps that to a value 81 00:03:12,230 --> 00:03:14,270 like 1. And you can see here there's a 82 00:03:14,270 --> 00:03:15,980 whole bunch of different information 83 00:03:15,980 --> 00:03:19,040 that is mapped to different keys. And so 84 00:03:19,040 --> 00:03:22,430 if we think about this we can see maybe 85 00:03:22,430 --> 00:03:23,750 why it's helpful to think of our 86 00:03:23,750 --> 00:03:25,880 services of black box. All we did here 87 00:03:25,880 --> 00:03:27,890 was provide a very simple input, just 88 00:03:27,890 --> 00:03:30,140 this URL and the fact that it was a GET 89 00:03:30,140 --> 00:03:32,480 request, and we turned we got this whole 90 00:03:32,480 --> 00:03:35,720 object full of rich information and data 91 00:03:35,720 --> 00:03:38,480 for us. But we have no idea about the 92 00:03:38,480 --> 00:03:40,910 implementation details, like what kind of 93 00:03:40,910 --> 00:03:42,320 database they used, what kind of 94 00:03:42,320 --> 00:03:43,850 programming language it was written in, 95 00:03:43,850 --> 00:03:45,290 how they pull all this data together, 96 00:03:45,290 --> 00:03:46,970 where they're getting it, maybe it's from 97 00:03:46,970 --> 00:03:49,400 multiple databases, we don't know. All we 98 00:03:49,400 --> 00:03:52,130 know is that if we give this URL and 99 00:03:52,130 --> 00:03:56,330 this GET command to the GitHub API, we'll 100 00:03:56,330 --> 00:03:58,160 get back a summary of the information 101 00:03:58,160 --> 00:04:01,580 about that user. And so when we think of 102 00:04:01,580 --> 00:04:03,110 it in this way it helps us to abstract 103 00:04:03,110 --> 00:04:05,330 the way underlying details, and to focus 104 00:04:05,330 --> 00:04:09,410 on testing it as a black box. And that's 105 00:04:09,410 --> 00:04:11,690 it for this video. So in the next video 106 00:04:11,690 --> 00:04:13,130 we're going to be talking about mapping 107 00:04:13,130 --> 00:04:18,130 your APIs, and I hope to see you there.