YTread Logo
YTread Logo

Session1: Introduction to API Testing

Mar 20, 2024
database and retrieve the data and send it back to the business logic layer and the same business logic will again send the response to the client, so this is an indirect process, so between the client and the database there will be one more layer, called business logic layer. we can say business lodge which contains a business logic, normally we call it ml application server, web servers, there are many things, so generally we can divide them into three parts so that all the web applications, all the web applications, are under a 3D architecture or follow the image of three earths, so there are so many client applications that will run.
session1 introduction to api testing
The business logic layer will be there and then the database layer will be there. These are the two different types of machines located in different locations, remote locations, so as a customer we don't actually know what is happening on the back end, so what kind of business logic is being executed? what type of database where exactly our data is stored, so it is not visible as a client or as a user. I can't see all of them, but as a client we can browse the data we can send the request to the server and we can get the response from the server, but who is taking the request, we say who processes it who sends the response those things are completely backend, they are invisible for the user This is how the web application actually works.
session1 introduction to api testing

More Interesting Facts About,

session1 introduction to api testing...

Again, if I divide it into three parts, we can call them presentation layer, application layer and data layer, we can classify them into two sections or two parts, one is the presentation layer and then the application layer. and a data layer, a presentation layer, is nothing but a user interface, a user interface that we can access the application through the browser, that is called presentation layer, it will present the data that comes from the server and the application layer which means which business logic the application layer contains a Logically even the web server also comes in this particular middle layer the application layer web server or we can say application server and server web, so these two come under the middle layer and then the database layer is a third layer which is also called data layer. presentation layer application layer and data layer so every web application will have three components or three sections like a presentation layer application layer and data layer so presentation layer what is the purpose of presentation layer here is which will present the data to the user which is basically called client and what is an application layer which has business logic and what is the purpose of application layer which will take the request from presentation layer the same request again will be sent to the data layer and the actual data layer contains what actually contains the data and whatever request we send, the corresponding data will be available in the data layer, so the application layer will send the same request to the data layer and the data layer will face the data and again response will be given to the application layer and this application layer will again send the response to the presentation layer, this is how exactly the web application works between the application layer of the presentation layer and the data layer and these three are the three different components of the web application now to the presentation layer normally to develop the presentation layer web applications or the developers will use this Technologies like HTML JavaScript CSS, for so all these are scripting languages ​​so by using these cryptic languages ​​the developer will develop the user interface or web applications which we can see in the browser so presentation layer is nothing but web applications .
session1 introduction to api testing
All web applications are under presentation. layer so these web applications will be developed by the developers using HTML JavaScript and CSS these are scripting languages ​​and applications are the application layer which contains a business logic and who will develop the business logic again the developers will develop the business logic by using programming languages ​​like java.net C Sharp Python C plus plus then here real programming languages ​​came into the scene so by using programming languages ​​developers will develop the business logic and that Business logic is investigated within the application layer, which is now the secondary layer, now the data layer of the third layer. which is also called database layer, the database layer is nothing more than here we install some databases like MySQL or it can be Oracle or SQL server or mongodb or any other database that is on the market and we can use one of the database as a database layer which is also called data layer and the actual data resides inside the database only because the database can only hold the data and the application layer which is the purpose of the application layer the processing the processing will be done by the application what is the processing here? again we will send the data from the presentation layer which we will request and then the application layer will receive the request and the same request will be sent again to the data layer and we will get the response and the same response will be presented in the presentation layer so that these three things will be done internally works for any type of web applications, but as a user, which we can access only in the presentation layer, that means we can see the application, we can work with the web applications, all this is found in the presentation layer, so the data layer of the application layer is invisible, so we can't access them directly, well, this is the basic understanding of what the client and server architecture is.
session1 introduction to api testing
Well, in each tile, like in one, two tires and Twitter, we will also have a server. Well, we can have a server, but the The server will be there on the same machine if you go for the Wonder architecture, we can have the server on the same machine and the tutor architecture. There are also several machines. There are two terms, it means that during two terms, at least two components must be there. The client is different and the server. It is different here the database acts as a server, so two different components are two different machines and in all three they interact the texture is again divided into three components the client is different the business logic is different the database is different and these three will be located in three different places and again there will be many clients, there will be many application servers, there will be many database servers, but in general, the architecture level, if you talk, we will convert it, we will classify it into three different parts of the client business logic, which is basically application layer and then database layer, okay, presentation and data application layer, so first we need to understand, uh, these three very, very important things, okay now let's try to understand more details, so what is an API?
Okay, so we understood what the presentation layer is, what it is. application layer what is database layer but where exactly does API come into the picture then what is an API now let's try to understand this in detail interface application programming interface then this is the complete form of application programming interface ABR so what is the EPA where exactly reset and what is the purpose of this API so AP is basically used to communicate between two applications let's say there are two different applications and they want to communicate with each other and there should be some mediator there should be some mediator and that is Basically it is called API so API is a way of communication between two applications where the applications may differ in their platforms or in terms of technology so those applications will be developed on different platforms and those applications will have different functionalities, but we will still combine them. applications we can communicate with each other using API so for example let's take here front end applications we have a front end application here so in front end application this is basically a web right so which this is basically a web application so this is our web so we discuss three layers one is for presentation layer so it is called presentation layer and this is called uh in the middle layer we can say application layer or application server or we can say uh web server in the middle layer and this is called application backend or we can say data layer or data database server okay three components so what are we going to do in web application in presentation layer?
We will try to access the application through the UI and send some requests to the middle layer which is actually the APL layer here the actual APIs will be reset so the API is nothing but what contains a logic business logic, so as we already discussed in the middle layer, we have a business logic inside it, but the business logic is available in the form of an API, the business logic is nothing more than an API, so eBay contains a business logic that is developed by the Developers so that when you send the request to the server or when you send the request first, it will go to the middle layer and what is in the middle layer we have different types of API, for which there are many types of AP available in the middle layer and according to our request the corresponding API will be activated and that APA, what that APA will do again, that AP will send the same request to the server which is a database layer and fetch the data here and provide the response to the presentation and who sends who takes the request who sends us the response API well, EP is taking the request and APS itself sends the response to the presentation layer, that means APA acts as a mediator between the presentation layer and the database layer and where exactly these apis are present, the apis are present within the middle layer, which is the business logic, which contains a business logic, so it will do two things , which is the first? this is the responsibility of the API layer to get the data from the back-end and display it on the front-end and on the other hand it is the responsibility of the API.
This is also the responsibility of the API layer to take the data from the front-end and push it to the back-end so that it takes the data, it will take the request from the front-end again, send it to the back-end and get the response and provide the same response to the presentation layer or front input and this is a mediating application programming interface. There is actually a full-format API, what does that mean? Basically, it's in the app. Application means that which contains some functionality and helps the application. Where exactly we are using the application. Here we are using the application.
So what does the API do? It is receiving the request from the application by sending response to the application, so it is an application programming means what it contains a programming logic and it is also an interface means what it is acting as a mediator it is acting as an interface between our front -end and our backend applications, that is the reason why the name says application programming interface API and where exactly these apsr reside in the middle layer APS will be available now when you test on this particular layer which is included in the web

testing

okay we use selenium there here and when you do the

testing

directly on this particular layer which is called API testing then when you do the testing on the database layer which is called database testing three different layers are fine and one thing we need to understand if you want to do web testing or web testing if you want to do it through the browser we can access the web application so that we can see the whole user interface and we can interact with the elements and we can do the web testing, but how come we test apis and why do we need to test eaps here?
So if you do the web test directly, where exactly we get the data from in the web application, AAP just provides the data directly through the apis that we are getting the response in the UI and what exactly we are validating in web applications, we are validating the data, we are validating the functionality on the website or on the web testing side, but where exactly are we getting the data from, where exactly are we getting it from. this functionality only through   APS we get it and if eaps are not available our web applications will not work because the web application actually needs the data and functionality which actually comes from what the AP middle layer provides so we are doing the tests on the website, but what kind of tests do we do here,we will do a paid test as part of API testing.
What you will do, instead of testing this web application, we will directly send the request to the API and we will receive the response from the API and we will test the response, we will do some validations on the response. The same thing is happening on the front-end as well, for example when you are testing the web applications, now we are testing the web here, so what exactly are you testing? here is any response provided by API, because when you send any request through web application, eapas give the response and this response we are testing in UI, so instead of testing in UI , what we will do directly we will access the apis and we will send the request to the API directly and we will get the response from the API directly and we do the tests here, so this is an APA test, so instead of testing in the web we will directly make the response data in Json formatter ok most of the time we use Json as request and response in next sessions I will discuss more about Json so this is response data so email id of user username last name   Avatar, so this is this is the information that we got from the server when you sent the get requester.
Okay, this is called a payload, yes, and we can directly send the same request, so for example, this is a host. Actually, okay, this is the host. Look here. So this is a host. and what is an endpoint this is the endpoint this is the endpoint so this is the endpoint let me copy this okay so this is the endpoint let me copy and I'm just adding the endpoint to the URL here Okay, and this It's a complete URL, guys. Well, if you send this request directly to the browser like this, you can also get the response.
Now we can see that this is the response, but here they have provided built-in options to send a get request. Placement request. Publication requests. and so on, every time you click on this button, the corresponding request will go and we will get the response, so whatever response that I have captured here, the same response that we also captured here, the same response, okay, this is how we should send the request ab, this is a get. request then there is a reason why we got the data and similarly let me send one more, suppose I want to get the single user data from the database so I will send the get so you don't need to confuse anything, guys, for now you can just consider the URL URI to be the same   okay, there is no confusion, you can consider it as one way.
The URL URI is the same, okay   no confusion, that's not very important actually  okay, so when you click on the get request this time, I get the data of the single user data of the single user that I got now this time what is   the request is a bar API user Bar 2 and  this is now we got the response to 200 200 is   nothing but what successful request if the request is done successfully then you will get the 200 .   and also we have different response codes like 200 201 401 501 different types of response codes based on that we can decide whether the request completed successfully or not so now with the same request I want to test through my browser how can we test new the same   host I can put here first, okay, the same host and  what is the endpoint to get the unique user   what is the endpoint to get the unique user  this is the endpoint APA slash for users slash   to users slash apa slash two so I can say APA slash users slash two so when I say two here I will get the information about the second user so let me copy it and send it in the browser so even through the browser we can also send the request and we can get the response from the API, but not everything is possible through the browser, only three are possible.
It is possible to get the request through the browser, but when you post a request, delete a request, or make a request through the browser, it is not possible. Ok we have to use different tools like Postman so here it is only possible to get a request through the browser so I send the full URL here and then I got the information of the unique user so when it says send to here I got the id2 here so I got the user information, the second user information, I guess I want to get the third user information, I can say three here, then I got the third user information, so I am sending a request and then I received a eapi response which is also the get request.
Now let's look at one more type of request so let's say this is a unique user not found and here you also get a list of resource requests and unique resources and creating the post requester means it will go and create a new user in the database for which we will use the post request and we will assume that the user is already available now I want to update then I can use the put request and the patch is also for updating and deleting requests, let's assume that the user is already there , then I want to delete the user and then I can send delete request for different purposes we can send different type of request but only through browser get requests are possible post request put request delete request these things are not possible through browser we have than to use some other tools that's why we can't use here ok the payload is nothing but the data which we will send through the requester payload is nothing but the data which will be sent through the request and they will get some data of the answer.
It is also a payload, for example I am sending the get request here. Are they sending any payload along with this request? Guys, answer. we are sending any payload with this requester payload we are sending any payload to this request no we are not sending any payload but once you send this request we are getting some response here yes we are getting some response data right , this is called payload response payload response payload sometimes you will send the post   the post request here click on the banner  when you send the post request ok we have to send some data and what is the using the post request which will create a new record in the database which will create a new record in the server and what are the details of that new record we have to pass.
If we pass a name and job accordingly, a new record will be created in the database, so this is called request payload along with this request URL. You also need to send some data, this is called a request payload and this is a response payload. Once you requested to create this data, it is created exactly this time and we are also given some response. Okay, so the payload is nothing more than a data request payload. it is nothing but the data which is sent through the request along with the request which is called as request payload, the data which is fetched from the response which is called as simple response payload, okay all these are sample API that they have provided and uh and the host is already here so just give us some endpoints here and we can export this API directly here when you click get here and when you submit this resource now, I have an answer here, this is also a get request and Suppose when you submit the post request click on post here and now this name and job are submitted through this request and we get a response here with the same name and job and with the uh some created it, suppose I want to delete some request then go to delete here and now here we need to pass some delete which one is deleted we move to we will not get any response data here because the data is deleted the record is deleted the response is what that two zero four is a response so some kind of request we have to send   payload and some kind of request we don't need to send any payload so 2 0 is 4 is nothing but   no content yes that record the second record is not in the database, so yes. they don't give content because these are all dumb APS, they may not take proper data, they may not give proper logs or proper response and starting tomorrow I will show you the different types of APs which are real APIs, exactly we are going to try, okay? and these are some fictitious APs just   so you understand.
I am just showing you these apis a different type of request and get request we can also send through browser also but after the request put request delete request this type of requests we can't send them so you need to understand one important thing , guys, every time you test an API, okay, every time you test an API, we have to pass some request, we have to pass some input, let's take any API, we need to pass some request and we will get some response and as part of the request what you will pass you will pass the data and you will pass the URL sometimes you will pass some keys some class sometimes you will pass authenticated information many things we have to send two requests sometimes but each APA may not require everything except sometimes we have to pass something related to this along with the request and whenever we get some response we will get some response data we will get a response status code and we will get some cookies we will get some response headers so many things we will get as part of the response so we need to validate all things and that is part of API testing so as an APA tester job what is our responsibility to know what kind of request we have to send to the API that we have. to know what kind of response it should return and accordingly we have to test the response, we make many variations on the response and that is what APA testing means, that is what API testing means, then the Apes and then this AP integrates with the web application now this Webby application will interact with the API now whatever transactions are done on this web everything will happen through APA so basically whatever operations let's do on the web, these operations will go to AP in the form of request and the API will return the response uh APA will return the data to the web in the form of sponsor, so instead of testing this web, if you test this API directly by sending a request and a response, our API testing job is done, so this is exactly what API testing means.
So guys you understood that now there are so many apas exposed from different types of companies, like we have Google Maps API, we have Facebook apis and we also have LinkedIn apis, so GitHub apis, so there are many types of APIs, some of them are free. we can access some of them or require some authentication information and some of them we cannot access directly because they are more sensitive epas, companies will use their internal purpose, so all payment gateways are also APS, so when you make some type of payment will be shown has different payment options like payment, net banking, credit card, debit card, internally it has its own APIs so when you select internet banking option it will activate some type of API and when you use the payment option is UPI, that will activate another type. of API, everything happens only through apis, but as a user we cannot see those apis internally once they are integrated, but at the time of testing we can access the apis developed by the developers and then we can test them.
Well, this is about an introductory part, like what is API testing, what is client server or texture and what exactly is API testing, how does API work, what are the different types of requests, so we have understood these things as part of hints. feeling in the next session we will try to install the Postman tool and then we will start manual testing of the APIs. Okay, that's the plan. Is it clear to everyone in today's session? So I'll stop here for today's session and if you have any general questions. we will discuss

If you have any copyright issue, please Contact