REST, HTTP and WebSocket APIs
Choose the API by the communication pattern
API Gateway receives client requests or WebSocket messages, selects a configured route and sends work to a backend. For a bookstore, a browser can ask for GET /books and receive a JSON list. The gateway is not the database or the business logic. A REST API and an HTTP API are two AWS product types that both support HTTP request/response; a REST API is not the only way to design a REST-style interface. A WebSocket API supports a persistent, bidirectional connection for messages such as order-status notifications.
Compare capabilities before choosing
For an ordinary JSON API with Lambda and token authorization, an HTTP API is a useful starting point. Choose the REST API product when you need its built-in request validation, usage plans and API keys, per-client throttling, private API endpoints, or stage caching. These are product capabilities, not requirements of the REST architectural style. An HTTP API can have a private backend integration without itself being a private API endpoint. For live notifications, WebSocket routes such as $connect and $disconnect handle connection lifecycle; a message route can be selected from a field such as action. The application still handles reconnects and missed updates.
Read a small route contract
A route identifies an operation, not a physical server. In the offline bookstore contract, GET /books lists the caller’s books; POST /books creates one; GET /books/{id}, PATCH /books/{id} and DELETE /books/{id} read, change and remove one record. The braces denote a path parameter. The backend checks ownership on each operation. HTTP method conventions matter: GET should not change business data. A WebSocket message such as {"action":"subscribe"} belongs to a different contract and is not an HTTP GET. A successful connection does not authorize every later message.
Practice: select a service type
A team needs private API endpoints for staff, built-in request validation and a usage plan for partners. Select REST API and separately design real authorization. A public-facing JSON catalog with a JWT authorizer may use HTTP API; a live dashboard may use WebSocket API alongside an HTTP snapshot endpoint. Verify the feature matrix and regional support before deploying. No account is needed for this exercise.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
REST, HTTP and WebSocket APIs — knowledge check
Reason about a fictional bookstore API without cloud access.
A catalog needs JSON request/response and JWT authorization but no advanced REST-only features. Which is a reasonable starting point?
A staff API needs a private API endpoint and built-in request validation. Which product fits?
A dashboard needs unsolicited updates over a persistent connection. Which API suits it?
Which operation should not modify a book record?
A user opens a WebSocket connection. What must the application still do?