What Is An API?: Integration of An E-Commerce Site With Payment Infrastructure
What Is An API?: Integration of An E-Commerce Site With Payment Infrastructure
What is an API?
API stands for "Application Programming Interface".
It is a system that enables communication between different software.
You can think of it as two people speaking different languages communicating through an interpreter. API acts
as an interpreter facilitating understanding between two different software and enabling data exchange.
Benefits of API
:
Security: Establishes a secure connection between two different servers.
Types of API
:
Internal API APIs used by specific individuals.
:
Open API APIs open to everyone's use.
:
Partner API APIs used between two companies.
:
Composite API APIs that combine multiple APIs.
:
API Architectures:
Facebook API
YouTube API
Examples:
Request
The areas we need to check when preparing an API Request:
(* Mandatory fields.
)
HTTP Request Types Get, Post, Put Patch, Delete)*
1
.
(
-
Base URL*
2
.
Endpoint*
3
.
Request Headers Location for Additional Information)
4
.
(
LinkedIn: Ahmet Beskazalioglu
API 1
Params
5
.
a Path
.
b Query
.
Request Body Mandatory for Post)
6
.
(
Authorization, Authentication Token)
7
.
(
Response
Status Code
1
.
a 1xx: The server acknowledges receiving your request and starts processing it.
.
b 2xx: The server indicates that it has successfully received, understood, and accepted your request.
.
i 200 Ok, 201 Created, 202 Accepted, 204 No Content)
.
(
→
→
→
→
c 3xx Indicates that additional steps are required to complete your request.
.
:
d 4xx The server cannot process your request because you may have made it incorrectly.
.
:
i 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 405 Method not Allowed)
.
(
-
-
-
-
-
e 5xx: Indicates that the server cannot process your request due to a server error.
.
Response Headers
2
.
Response Body Json) // There are 6 ways to verify the Body.
3
.
(
Validation Response Body
response.asString();
1
.
response.path("GPATH SYNTAX")
2
.
Jsonpath jsonpath = response.jsonpath();
3
.
Jsonpath.getString("GPATH SYNTAX")
HamCrestMatchers
4
.
RestAssured.
.given()
.when()
.get("BASEURL ENDPOINT")
+
.then()
...
401 Invalid credentials 403 You don't have sufficient privileges to perform the
:
:
operation.
401 Unauthorized
:
403 Forbidden
The API doesn't know who
:
you are. The API allows entry but with limited privileges."
It is XML-based.
Protocols: They can use various protocols including REST, SOAP, GraphQL, and more.
Flexibility: APIs are more flexible architecturally and provide a broader range of interaction between
applications on different platforms.
Web Services
Protocols: They are inherently tied to specific web technologies. They use protocols like SOAP (usually
transmitting data in XML format) and less commonly XML RPC, UDDI, etc.
-
Standards: Web services have stricter standards and protocols.
Compatibility: When it comes to cross-platform compatibility with systems built on different technologies,
web services may be more restrictive compared to APIs.
In Summary:
All Web Services are APIs, but not all APIs are Web Services.
Web Services are more rigid and use mandatory protocols like SOAP and XML. SOAP APIs typically
support an XML document called WSDL Web Service Definition Language) that defines the functionality
(
of the API.
Integrating different platforms: If you need to work with legacy systems using SOAP and require more
robust standards, web services might be appropriate.
High flexibility and different protocols: If you need a more flexible architecture or prefer lighter data
formats like JSON, APIs are a better choice.
Additional Notes:
In modern usage, the term "API" often refers to web-based APIs like REST APIs. However, APIs do not
require network connections (operating system libraries can also be considered APIs).
Web Services are now considered an older technology, and API types like REST have become more
popular.
Manual tests, on the other hand, are more effective in checking more complex scenarios using
human intelligence and intuitive understanding.
What do you pay attention to in API testing and how do you evaluate based on
which criteria?
Answer: Important aspects in API testing include the accuracy of inputs, whether outputs produce
expected results, handling of error conditions, security checks, and performance. Additionally, it's
important for the API to be well-documented, allowing users to easily understand and use it.
Which HTTP methods GET, POST, PUT, DELETE, etc.) do you use and when are
(
they used?
Answer:
Deleting a product.
What types of security tests are performed in API testing and why are they
important?
Answer: Security tests in API testing cover areas such as authentication and authorization controls,
data integrity, data accuracy, data privacy, and resilience against attacks. These tests are important
to ensure the security of the API and the protection of sensitive data.
B Group
What is API testing?
Answer: API testing is the process of testing the functionality, performance, and security of an API.
Group C
What is checked first after receiving the request?
Answer:
Status code
1
.
Headers Optional)
2
.
(
Response body Optional)
3
.
(
What is Serialization and Deserialization?
Answer:
Serialization: Serialization is the process of converting the state or structure of an object or data
structure in memory into a format suitable for storage. This process is typically done by converting
an object or data structure into a format such as JSON, XML, or binary. Serialization allows an
object's state to be transferred from memory to disk or over a network while preserving its state.
Summary:
It is the process of converting an object or data structure into a specific format for storage or
transmission purposes.
Summary:
It is the process of converting a serialized object or data structure back into its original form.
Why is it used?
Data Storage: Objects or data structures need to be serialized for storage on disk, in a database,
or over a network.
Interoperability: A common format is used for data exchange between different programming
languages and applications.
Example:
A Java application can serialize a user object to JSON format and send this JSON data to a web
API.
The web API can deserialize the JSON data back to a user object using deserialization and store
this object in a database.
What is an Endpoint?
Answer:
Endpoints retrieve specific data or trigger operations that modify data on the server.
House Analogy: Think of the API as a house. Endpoints are like doors leading to different
rooms in this house. The bedroom door leads to the bedroom, the kitchen door leads to the
kitchen, and so on.
Restaurant Analogy: Imagine the API as a restaurant. Endpoints can be thought of as the
dishes served in this restaurant. Each dish has its own URL /pizza, /hamburger, /salad, etc.).
(
What are XML and JSON concepts?
XML Extensible Markup Language): It is a markup language used to define and store data.
(
LinkedIn: Ahmet Beskazalioglu
API 7
JSON JavaScript Object Notation): It is a lightweight data interchange format used to represent
(
data.
Data is stored in a "Key" and "Value" format.
:
Feature XML JSON
Data Types Supports more data types. Supports fewer data types.
Used in areas such as web services, Used in areas such as web APIs, NoSQL
Use Cases
configuration files, data transmission. databases, data interchange with JavaScript.
Gson
Answer:
Gson is a Java library developed by Google for converting Java objects to JSON (serialization) and
JSON to Java objects (deserialization).
JSON is simple and works across different platforms. Gson is specifically designed for Java and
offers more flexibility.
Swagger
Answer:
Swagger is an open-source software used for designing, documenting, and testing APIs. With
features like easy design and creation, standard format, and live testing, it makes your API more
usable and developer-friendly.
As a tester we send a API request and verify the status code, response body and checking the
endpoints of the api URL is working as expected
Pozitive I send valid requests, headers, parameters, and JSON bodies, and verify that the
-
response is 200/201.
Negative I send invalid requests, headers, parameters, and bodies, expecting the response not to
-
be 200.
API Validation: Making sure each REST API endpoint works as expected.
Methods:
HTTP Requests: Sending requests to API endpoints using various HTTP methods like POST,
PUT, GET, DELETE.
Response Verification: Checking if the API returns the correct status codes 200, 400, 401,
(
500, etc.) and if the response content is as expected. Headers can also be verified.
(
response).
Negative Tests: Testing with invalid request parameters, headers, and JSON bodies to verify
that the API handles error scenarios (non-200 status codes and error messages) correctly.
Summary:
Use of appropriate tools for manual testing Postman) and automated testing Rest Assured).
(
(
RestAssured
Answer:
RestAssured is an easy-to-use, flexible, and comprehensive open-source library for testing REST
APIs in Java.
With RestAssured, you can test the functionality of API endpoints, verify expected responses and
error codes, and create automated test scenarios.
JsonPath
One of the ways to verify the response body.
Jsonpath jsonpath = response.jsonpath();