Basic Knowledge of API & API Testing
What is an API?
An Application Programming Interface (API) is a set of rules that lets different software systems communicate with each other — typically by sending requests and receiving structured responses (often in JSON or XML) over HTTP.
What is API Testing?
API testing verifies that an API's endpoints behave correctly — returning the right data, the right status codes, and handling errors appropriately — without going through a graphical user interface.
Why API Testing Matters
- It tests business logic directly, closer to where the real functionality lives.
- It is typically faster and more stable than UI testing.
- It can catch defects earlier, since APIs are often built before the UI.
How an API Call Works, Step by Step
Think of an API like a waiter in a restaurant. You do not walk into the kitchen; you give your order to the waiter, who brings back the dish. In software terms:
- The client (a mobile app, a website or a test tool) builds a request with a URL, a method such as GET or POST, headers and sometimes a body.
- The request travels over HTTP or HTTPS to the server.
- The server checks who is calling, validates the input and runs the business logic, often reading or writing a database.
- The server sends back a response with a status code and usually a JSON body.
- The client reads the response and shows the result to the user.
An API tester sits in the client's position, sends requests directly and checks every part of the response.
Your First API Test with curl
You can try a request from any terminal before learning a dedicated tool:
curl -i https://api.example.com/users/1
The -i flag shows response headers. A response might look like this:
HTTP/1.1 200 OK
Content-Type: application/json
{"id": 1, "name": "Neha", "email": "neha@example.com"}
A basic test asks three questions: is the status 200, is the content JSON, and do the fields hold the expected values? Next, try /users/99999, an ID that should not exist, and confirm the API returns 404 rather than an empty 200 or a server error. Replace the example address with the API you are allowed to test.
Types of API Testing
| Type | What It Checks |
|---|---|
| Functional | Each endpoint returns correct data for valid and invalid input |
| Contract or schema | Response structure matches the agreed specification, such as an OpenAPI document |
| Integration | Several APIs work together correctly, for example order and payment services |
| Security | Authentication and authorization are enforced and errors do not leak sensitive details |
| Performance | Response times and behaviour under expected load |
REST, SOAP and GraphQL in brief
REST APIs use standard HTTP methods on resource URLs and usually return JSON; they are the most common today. SOAP APIs exchange XML messages defined by a WSDL contract and are still found in banking and enterprise systems. GraphQL APIs expose a single endpoint where the client asks for exactly the fields it wants. The testing mindset is the same for all three, though the tools and request formats differ.
Common Tools and Beginner Mistakes
Popular tools include Postman for manual and collection-based testing, Rest Assured for Java automation, and libraries such as requests with pytest in Python. Whatever you choose, avoid these early mistakes:
- Testing only the happy path and skipping invalid or missing input.
- Ignoring authentication, so nobody checks what happens without a valid token.
- Relying on data that another tester might change or delete.
- Not reading the API documentation before writing tests.
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.