2024-03-28Hünkar Döner

What is HTTP API? The Language of Protocols

HTTPAPIWeb
W

What is HTTP API?

An HTTP (Hypertext Transfer Protocol) API is an interface that allows two systems to communicate using the HTTP protocol. While often used synonymously with REST API, technically any API running over HTTP (SOAP, GraphQL, REST) is an HTTP API.

Evolution of HTTP

  • HTTP/1.1: The standard for many years. Used new TCP connections (or keep-alive) for requests.
  • HTTP/2: Improved performance with multiplexing (multiple requests over a single connection).
  • HTTP/3: Built on QUIC protocol, faster and more secure.

HTTP API vs REST API

In platforms like AWS, you might see a distinction between "HTTP API" and "REST API":

  • REST API (AWS context): Offers more features, validation, and transformation capabilities but can be costlier.
  • HTTP API (AWS context): Lighter, lower latency, and more cost-effective, but lacks some advanced features.

Request and Response Cycle

An HTTP API request includes:

  1. URL: The address to reach.
  2. Method: The action to perform (GET, POST, etc.).
  3. Headers: Metadata (Auth token, content-type).
  4. Body: Data sent (optional).

The server returns a Status Code (200 OK, 404 Not Found, 500 Error) and a Body (JSON response).