What is an Endpoint?
An API Endpoint is the specific URL through which a client communicates with an API.
Each endpoint represents a particular resource or operation and is accessed using HTTP methods such as:
- GET
- POST
- PUT
- DELETE
- PATCH
Endpoints can also include:
- Path parameters
- Query parameters
Example
Retrieve user details using:
GET /users/{id}
Interview Tip:
"We followed RESTful naming conventions by using endpoints like/usersinstead of/getUsers, and we secured sensitive endpoints using authentication and authorization."
HTTP Request and Its Components
An HTTP Request is a message sent by the client to the server requesting an action or resource.
Components of an HTTP Request
HTTP Method
Specifies the operation to perform.
Examples:
- GET
- POST
- PUT
- PATCH
- DELETE
URL (Endpoint)
The address of the API resource.
Example:
https://api.example.com/users
Headers
Contain metadata about the request.
Examples:
- Authorization
- Content-Type
- Accept
Request Body (Optional)
Contains data sent to the server.
Typically used with:
- POST
- PUT
- PATCH
Interview Tip:
"An HTTP request contains the HTTP method, endpoint URL, request headers, and an optional request body. We used Bearer Tokens for authentication and JSON payloads for sending request data."
HTTP Response and Its Components
An HTTP Response is the server's reply to an HTTP request.
Components of an HTTP Response
Status Code
Indicates whether the request was successful or failed.
Examples:
- 200 OK
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 404 Not Found
- 500 Internal Server Error
Headers
Provide metadata about the response.
Common headers include:
- Content-Type
- Cache-Control
- CORS
- Content-Length
Response Body (Optional)
Contains the actual data returned by the API.
Most REST APIs return JSON responses.
Interview Tip:
"We validated HTTP status codes, verified JSON response bodies, and checked important response headers such as Content-Type, Cache-Control, and CORS."
Request Headers
A Request Header is a key-value pair that provides additional information about an HTTP request.
Headers communicate metadata to the server.
Common Request Headers
| Header | Purpose |
|---|---|
| Authorization | Sends authentication credentials |
| Content-Type | Specifies the request payload format |
| Accept | Specifies the expected response format |
| Cache-Control | Controls request caching |
Example
Authorization: Bearer <access_token>
Content-Type: application/json
During API testing, verify that:
- Authentication headers are correct.
- Content-Type matches the payload.
- Required headers are present.
Interview Tip:
"We validated Authorization and Content-Type headers to ensure requests were authenticated correctly and payloads were sent in the expected format."
Request Body
The Request Body contains the data sent from the client to the server.
It is commonly used with:
- POST
- PUT
- PATCH
Common Request Formats
- JSON
- XML
- Form-data
- x-www-form-urlencoded
Example
{
"name": "John",
"email": "john@example.com"
}
When testing request bodies, verify that:
- Required fields are present.
- Data types are correct.
- Payload format is valid.
- Business validation rules are followed.
Interview Tip:
"We ensured request payloads contained all mandatory fields and validated that the API correctly stored and returned the submitted data."
Response Body
A Response Body contains the data returned by the server after processing a request.
Most REST APIs return JSON responses.
Example
A successful request:
GET /users/101
may return:
{
"id": 101,
"name": "John",
"email": "john@example.com"
}
When testing response bodies, verify:
- Response structure.
- Required fields.
- Returned values.
- JSON Schema.
- Data types.
Interview Tip:
"We validated response bodies by checking returned values, verifying required fields, and performing JSON Schema validation in Postman."
Query Parameters
Query Parameters are optional key-value pairs appended to the URL to customize the API response.
They are commonly used for:
- Filtering
- Sorting
- Searching
- Pagination
Format
?key1=value1&key2=value2
Examples
Filter active users:
/users?status=active
Pagination:
/users?page=2&limit=10
Best Practices
- Encode special characters properly.
- Validate missing parameters.
- Test invalid parameter values.
- Verify default behavior.
Interview Tip:
"We tested query parameters using valid, invalid, and missing values to ensure filtering, pagination, and sorting behaved correctly."
Path Parameters
Path Parameters are dynamic values embedded directly within the endpoint URL.
They identify a specific resource.
In API documentation, they are represented using curly braces {}.
Example
/users/{id}
Actual request:
/users/123
Characteristics
- Part of the URL path.
- Usually mandatory.
- Used to identify a specific resource.
- Commonly used with GET, PUT, PATCH, and DELETE requests.
Interview Tip:
"While testing path parameters, we verified responses using valid IDs, invalid IDs, non-existing IDs, and missing values to ensure proper error handling."
Query Parameters vs Path Parameters
| Aspect | Query Parameters | Path Parameters |
|---|---|---|
| Location | After ? in the URL |
Inside the endpoint path |
| Format | ?key=value |
/resource/{id} |
| Purpose | Filter, sort, paginate, customize | Identify a specific resource |
| Mandatory | Usually optional | Usually mandatory |
| Example | /users?status=active&page=2 |
/users/123 |
Summary
- Path Parameters identify a specific resource.
- Query Parameters customize or filter the returned results.
FAQs
What is an endpoint in API testing?
An API endpoint is the specific URL through which clients communicate with an API. Each endpoint represents a particular resource or operation and is accessed using HTTP methods such as GET, POST, PUT, PATCH, or DELETE.
What are the key components of an HTTP request?
An HTTP request consists of:
- HTTP method
- URL (endpoint)
- Request headers
- Optional request body
What are the key components of an HTTP response?
An HTTP response consists of:
- HTTP status code
- Response headers
- Optional response body
What is a request header?
A request header is a key-value pair that provides metadata about an HTTP request, including authentication, content type, accepted response format, caching information, and other request details.
What is a request body?
A request body contains the data sent from the client to the server, typically used in POST, PUT, and PATCH requests. It is commonly formatted as JSON, XML, or form-data.
What is the difference between Query Parameters and Path Parameters?
- Path Parameters are part of the URL path and identify a specific resource (for example,
/users/123). They are usually mandatory. - Query Parameters appear after the
?symbol and are used to filter, sort, search, or paginate results (for example,/users?status=active&page=2). They are generally optional.