API Testing
API Testing
RESTful API:
It is based on a client-server model where each service is viewed as a resource that can
be accessed via standard HTTP methods (GET, POST, PUT, DELETE).
REST APIs are lightweight, easy to use, and widely adopted due to their simplicity and
compatibility with various platforms and programming languages.
They typically use JSON (JavaScript Object Notation) for data exchange, which is
lightweight and easy for both humans and machines to read and write.
RESTful APIs are stateless, meaning each request from a client contains all the
information necessary for the server to fulfill it, without requiring the server to store any
session information.
2. SOAP API:
It relies on XML (Extensible Markup Language) for message format and HTTP or SMTP
for message negotiation and transmission.
SOAP APIs are more rigid and complex compared to RESTful APIs, often requiring
specialized tooling for development and consumption.
They offer features like security, transactions, and reliability, making them suitable for
enterprise-level applications where these features are crucial.
SOAP APIs support more advanced functionalities such as RPC (Remote Procedure Call)
and messaging standards like WS-Security.
Feature/
Aspect REST API SOAP API GraphQL
XML-based, transport
Protocol HTTP agnostic (HTTP, SMTP) HTTP
Architecture
Style Resource-based Protocol-based Query language
Data Format JSON, XML, HTML, etc. XML JSON
Endpoint Multiple endpoints (one Single endpoint for all
Structure per resource) operations Single endpoint
HTTP methods (GET, POST, Specific operations
Operations PUT, DELETE) defined in WSDL Queries and mutations
Can be stateless or
Stateless Yes stateful Yes
Standardized SOAP fault
Error Handling HTTP status codes messages Custom error handling
Security OAuth, JWT, SSL/TLS WS-Security, SSL/TLS OAuth, JWT, SSL/TLS
Easy to implement HTTP More complex, less Challenging, custom
Caching caching common solutions needed
Documentatio Self-documenting via
n Swagger/OpenAPI, RAML WSDL schema
Simple, easy to Complex, steep learning Moderate, requires
Ease of Use understand curve understanding schema
Higher overhead due to Efficient, but initial
Performance Efficient, less overhead XML and envelopes overhead
CRUD operations, simple Enterprise applications, Complex queries, mobile
Use Cases services complex transactions apps, social networks
Scalability, simplicity, Reliability, formal Efficiency, flexibility,
Advantages flexibility contracts, extensibility reduced data transfer
Over-fetching/under- Complexity, performance
Disadvantages fetching overhead Complexity, caching issues