APIs and HTTP form the backbone of modern web communication. Below are the most important API & HTTP interview questions every developer should know.
๐น What is an API and why do we use it?
- API (Application Programming Interface) โ A set of rules that allow software applications to communicate with each other.
- Use: Enables integration, automation, and reusability (e.g., payment gateway, social login, weather services).
๐น What are HTTP Methods?
- GET โ Retrieve data.
- POST โ Create new resources.
- PUT โ Update/replace entire resource.
- PATCH โ Partially update resource.
- DELETE โ Remove resource.
- HEAD โ Retrieve headers only.
- OPTIONS โ Discover supported methods.
๐น GET vs POST
- GET โ Idempotent, data in URL, not secure for sensitive info, limited length.
- POST โ Non-idempotent, data in body, secure for large/sensitive payloads.
๐น PUT vs PATCH
- PUT โ Replaces entire resource.
- PATCH โ Updates specific fields in resource.
๐น PUT and POST
- PUT โ Used for updating/replacing. Idempotent.
- POST โ Used for creating. Non-idempotent.
๐น SOAP API and Its Use
- SOAP (Simple Object Access Protocol) โ XML-based protocol for exchanging structured information.
- Use: High security, reliable messaging, enterprise systems like banking/telecom.
๐น REST API
- REST (Representational State Transfer) โ Architectural style using HTTP for CRUD operations on resources.
- Lightweight, scalable, widely used in web/mobile apps.
๐น SOAP vs REST
- SOAP โ Strict, XML only, heavier, built-in security.
- REST โ Flexible, supports XML/JSON, faster, easier to use.
๐น HTTP Status Codes
- 1xx โ Informational.
- 2xx โ Success (200 OK, 201 Created).
- 3xx โ Redirection (301 Moved Permanently).
- 4xx โ Client Error (400 Bad Request, 404 Not Found).
- 5xx โ Server Error (500 Internal Server Error).
๐น Components of HTTP Request & Response
- Request โ Method, URI, Headers, Body (optional).
- Response โ Status line, Headers, Body (optional).
๐น GET/POST Instead of PUT for Resource Creation
- While POST is standard for creation, some APIs use PUT if the client knows the resource URI.
- Using GET for creation is a bad practice (GET should be read-only).
๐น RESTful Web Service & Features
- RESTful WS โ Service following REST principles.
-
Features:
- Client-server architecture
- Stateless communication
- Uniform interface
- Cacheable responses
- Layered system
๐น Disadvantages of RESTful Web Services
- No strict standards (loose rules).
- Less secure compared to SOAP.
- Overhead of multiple requests for complex operations.
๐น Whatโs Payload?
- Payload = Actual data sent in request/response body (e.g., JSON/XML).
๐น Can We Send Payload in GET or DELETE?
- Technically possible but not recommended.
- HTTP spec doesnโt forbid it, but many servers/proxies ignore it.
๐น Max Payload Size in POST
- No official limit in HTTP spec.
- Practical limit depends on server (e.g., Apache, Nginx default ~2MB to 100MB).
๐น Markup Language for REST API
- REST supports multiple formats, most commonly JSON and XML.
๐น XML vs JSON
- XML โ Verbose, supports attributes, widely used in SOAP.
- JSON โ Lightweight, human-readable, faster, widely used in REST.
๐น Whatโs Resource in REST & How to Present?
- Resource = Any entity (user, product, order).
- Represented by URI (Uniform Resource Identifier).
Example:
/api/users/123
๐น Advantages of REST in Web API
- Lightweight and scalable.
- Platform/language independent.
- Uses existing HTTP methods.
- Easy to integrate with web/mobile.
๐น Concept of Statelessness in REST API
- Each request contains all info (no server-side session).
- Improves scalability, reduces server memory usage.
๐น Whatโs URI?
-
URI (Uniform Resource Identifier) โ Unique address for a resource.
Example:
https://api.example.com/products/1
๐น CORS in Web API
- CORS (Cross-Origin Resource Sharing) โ Security feature of browsers.
- Allows or restricts requests from different domains.
๐น Whatโs Postman & Its Use?
- Postman โ API client tool for testing, documenting, and automating API calls.
- Widely used for debugging and collaboration in teams.
โ Conclusion
APIs and HTTP form the foundation of modern web services. Knowing HTTP methods, REST principles, SOAP vs REST, status codes, payloads, and tools like Postman is critical for acing interviews and real-world backend development.
Top comments (0)