What is API
Ultimate API guide
Contents
What is API
Application Programming Interface: allows two applications to talk to each other
What is REST API
REST (Representational State Transfer): A set of functions for developers to perform requests and receive responses using HTTP protocol
Challenges under API testing
- API Documentation (need endpoint, parameters, resources, data)
- Access to DB (Validate response by comparing response to DB)
- Authorization overhead (Handle tokens)
Core components of HTTP request
- HTTP request methods
- URI
- Resources and parameters
- Request header (JSON, XML)
- Request body (message content)
What is Payload
- Payload/body is secured input data sent to API
- In JSON
What is JSON
- JavaScript Object Notation
- Data format represented as String-text
Authentication Techniques used in API’s
- Session/Cookie based Authentication
- Basic Authentication
- Digest Authentication
- OAuth
Why API testing is suitable for automation testing
API testing is:
- Light-weight
- More stable than UI testing
What to verify in API testing
- Verify the accuracy of data (if is as expected)
- Check HTTP status code
- Response time
- Error codes if API return errors
- Check Authorization
- Non-functional testing
Path parameter and Query parameter
// below is an API request URL
http:/abcd.com/orders/11234?location=IND
// End point: http:/abcd.com
// Resource: orders
After / : path parameter
After ? : query parameter
API testing vs UI testing
API: back-end
UI: front-end
Soap WebServices
Simple Object Access Protocol: it is a XML based message protocol
Serialization && Deserialization
Serialization: Convert Java obj –> JSON (Request body/payload)
Deserialization: Convert JSON –> Java obj
JSON path example
courses[0].details.site
API calling examples
Python:
|
|
Dart:
|
|