CoAP (Constrained Application Protocol) is a RESTful application protocol designed for constrained devices and networks, it deliberately mirrors HTTP's model (GET/POST/PUT/DELETE methods, resources addressed by URIs, response codes analogous to HTTP's) but runs over UDP with a compact ~4-byte binary header instead of HTTP's verbose text headers over TCP. You'd use it instead of HTTP when the device is tiny and power- or bandwidth-constrained: HTTP+TCP requires a connection handshake, large headers, and per-connection state that are too heavy for a coin-cell sensor that wakes briefly, sends a reading, and sleeps, whereas CoAP's connectionless UDP exchange is a single request datagram and a single response datagram, minimal overhead, minimal state, fast, and low energy. Because it intentionally maps onto HTTP semantics, CoAP is also easy to bridge to the web through a proxy. The tradeoff is that UDP is unreliable, so CoAP adds its own lightweight, optional reliability rather than getting it for free from TCP. So CoAP is "REST for the smallest nodes," chosen when HTTP's weight is the problem.
Networking & IoT · Interview question
What is CoAP and why use it instead of HTTP?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
CoAP
REST for tiny devices: CoAP brings HTTP-like GET/POST/PUT/DELETE to constrained nodes over UDP with a 4-byte header, optional confirmable reliability, Observe push, and DTLS security.