
REST, GraphQL, Webhooks, or Polling: How to Choose
Integration pain that looks like a bad vendor can be a style mismatch. Choose sync, push, or pull from the need with a decision matrix and small webhook-vs-polling code examples.
TL;DR: The integration style is a property of the need, not a technology preference. Start from three questions — how fresh must the data be, how long can the caller wait, and who initiates the exchange — and the style picks itself: synchronous request/response for reads and writes the user waits on, webhooks when the event originates at the vendor, polling as the fallback when no webhook exists. This article gives you a need-to-style decision matrix and small illustrative code so each integration in a website or shopping mall build is matched on purpose.
The decision is the need, not the technology
Integration pain that looks like a bad vendor can be a style mismatch. A team polls a payment provider every few seconds because polling is the pattern they reached for last time, and then spends the run-up to launch tuning polling intervals that a webhook would have made unnecessary. Another team forces an event that originates at the vendor through a synchronous call and discovers that the user is now waiting on something the vendor cannot return in time.
The way out is to decide from the need, before the technology. Three questions answer it. How fresh must the data be — is stale-by-minutes acceptable, or must it be the moment it changes? How long can the caller tolerate waiting — is this on a path where a human is staring at a spinner, or can it complete out of band? And who initiates — does your application reach out to the vendor, or does the vendor reach out to you when something happens? Those answers, not a framework allegiance, select the style. Neither REST nor GraphQL nor webhooks is a default; each is a tool mapped to a shape of need.
The cost of getting this wrong is not abstract. A style mismatch does not announce itself in development, where volumes are low and timing is forgiving; it surfaces under real traffic as the symptom you end up chasing at launch. Polling an event that should have been a webhook can show up as rate-limit exhaustion and a tuning exercise that is hard to stabilize. Forcing a vendor-originated result into a synchronous call can show up as timeouts that look like a flaky vendor but are actually the wrong question being asked. Diagnosing a style mismatch as a vendor problem is one way teams spend effort on the wrong fix, because the call works often enough to look healthy and can fail exactly when it matters.
Synchronous request/response
Synchronous request/response is the right tool when the caller waits and needs an answer now: a product lookup, a price check, an address validation, an order submission. Within synchronous, the choice between REST and GraphQL is also need-driven, not tribal.
REST fits resource-shaped interactions with cacheable reads and well-understood write semantics. Its method and caching behavior is specified — RFC 9110 HTTP Semantics defines what a safe, idempotent, or cacheable request means — so these are contract properties, not hopes. A GET response can be reused from a cache at the edge under the conditions set by HTTP Caching (RFC 9111), and a PUT can be retried when the connection closes before any response arrives, with the same intended effect on the server even though the response might differ. GraphQL fits when the client genuinely shapes the response and over-fetching is a measured cost: a single screen that needs a deep, branching slice of data from one endpoint, where the alternative is several round trips or a fat fixed payload. The GraphQL query model earns its complexity when response shaping is a real requirement, and adds complexity for no return when the data is naturally resource-shaped.
The failure mode to name is using a synchronous call for the wrong job. A long-running operation, or one whose result originates later at the vendor, is not made synchronous by wrapping it in a request — it is made fragile. When the user would have to wait on something out of their control, synchronous is the wrong tool regardless of how clean the endpoint looks.
Asynchronous push: webhooks
Use a webhook when the event originates at the vendor and you cannot predict when. A payment captures, a shipment moves, a fraud review completes — these happen on the vendor's clock, and asking your application to discover them by repeated questioning is the wrong shape. The vendor calls you when the thing happens; that is the entire reason webhooks exist.
Two delivery properties drive the design and are not optional to account for. Providers that retry failed deliveries can send the same event more than once — Stripe's documentation says webhook endpoints might occasionally receive the same event more than once — so the receiver must be idempotent and deduplicate on the event identifier. And delivery order may not be guaranteed — Stripe's documentation, for example, says Stripe doesn't guarantee delivery in the order events are generated — so a later event can arrive before an earlier one, and the receiver must reconcile against state rather than assume sequence. A minimal receiver therefore verifies the signature, deduplicates, and records — it does not act on order or on a single delivery.
// Webhook receiver: verify, dedupe, record — never assume order or once-only
// req.rawBody: the unparsed body bytes, kept by your parser (e.g. express.json({ verify }))
app.post("/webhooks/payments", (req, res) => {
if (!verifySignature(req.rawBody, req.headers["x-signature"])) {
return res.status(401).end();
}
const event = req.body;
if (alreadyProcessed(event.id)) {
return res.status(200).end(); // duplicate delivery: idempotent ack
}
recordEvent(event); // reconcile against state, not arrival order
res.status(200).end();
});Because delivery can fail entirely — your endpoint was down, the network dropped it — and not every provider retries (GitHub's documentation says GitHub does not automatically redeliver failed deliveries), a webhook pairs with a pull API for reconciliation. The webhook is the fast path; a periodic pull of authoritative state is the safety net that catches whatever the push missed. Designing the push without the reconciliation pull is designing half the integration. The deeper mechanics of webhook verification, replay, and reconciliation belong to the webhook-focused treatment on this topic; here the rule is only that you choose push when the event is the vendor's to announce.
Pull: polling and its cost
Polling is the fallback, not a peer. You poll when there is no webhook and the data still has to become fresh on a schedule you control. It is a legitimate choice — many capable APIs offer no push — but it is chosen knowing its cost, not by default.
The cost is in the interval. Poll too often and you spend rate-limit budget and money on requests that mostly return "nothing changed"; poll too rarely and freshness suffers. A disciplined polling loop uses backoff so that an empty or failing response widens the interval rather than hammering a struggling vendor, and it bounds load with conditional requests or cursors so each poll asks only "what changed since last time."
// Polling loop: bounded interval, backoff on empty/failure, cursor to bound load
let interval = BASE_MS;
let lastCursor = null; // or a cursor persisted from the last run
async function poll() {
try {
const { changes, cursor } = await fetchSince(lastCursor);
if (changes.length === 0) {
interval = Math.min(interval * 2, MAX_MS); // back off when idle
} else {
process(changes);
lastCursor = cursor; // advance, do not re-scan
interval = BASE_MS;
}
} catch {
interval = Math.min(interval * 2, MAX_MS); // back off on failure
}
setTimeout(poll, interval);
}There is a second cost that scoping often misses: a polling loop is a standing system that has to be owned, observed, and reasoned about long after launch. It can consume rate-limit budget even on cycles where nothing changed — unless the vendor exempts unchanged responses, as GitHub does from its primary rate limit when a correctly authorized conditional request returns 304 Not Modified — it competes with the synchronous traffic that shares the same vendor ceiling, and its failure is silent — a poll that quietly stops returns no error to a user, only stale data nobody flagged. None of that makes polling wrong; it makes polling a deliberate choice with an ongoing operational weight, recorded in the inventory rather than discovered when the data goes stale.
The honest framing is that polling is what you reach for when push is unavailable, not what you reach for first. When a webhook exists and the event is the vendor's to announce, polling is the more expensive way to learn the same thing later.
Streaming and the edges
Two styles sit at the edges and are worth naming so they are not over-applied. Server-Sent Events and WebSocket connections are excellent for a live user interface — a status that updates in front of someone, a presence indicator — but they are not the default integration-layer choice between your backend and a vendor, where a webhook plus reconciliation does the job with less standing infrastructure. Batch and file transfer is the opposite edge: for bulk reconciliation, end-of-day settlement files, or large catalog syncs, a scheduled file exchange is often simpler and more auditable than a high-frequency API. Neither is a default; both are the right answer to a narrow, recognizable need.
The decision matrix
This is the deliverable. For each integration in the build, find the row that matches the need and the style follows.
| Need shape | Style | Website example | Commerce example |
|---|---|---|---|
| Caller waits, resource-shaped read or write | REST | Store-locator lookup, contact-form submit | Product fetch, order submission |
| Caller waits, client must shape a deep response | GraphQL | Aggregated dashboard panel | Cart + catalog + customer in one screen |
| Event originates at the vendor, time unknown | Webhook | Form-handler delivery callback | Payment capture, shipment status |
| No webhook, data must become fresh on schedule | Polling with backoff | Third-party content sync | Inventory reconciliation when no push exists |
| Live update in front of a user | SSE / WebSocket | Live event feed on a campaign page | Order-status screen during fulfillment |
| Bulk or scheduled reconciliation | Batch / file | Analytics export | End-of-day settlement file |
Read the matrix from the need column, never from the style column. The mistake teams make is starting at "we use REST" and bending the need to fit; starting at the need and letting the style fall out is what keeps an integration from fighting its own shape at launch. Auth and resilience mechanics — how the synchronous call is authenticated, how the webhook is verified, how the polling loop is observed — are real and necessary, but they are decided in their own treatments on this topic; this matrix decides only how each integration should talk.
Diagnostic checklist for the next planning cycle
- List every integration and write its need shape: freshness, wait tolerance, and who initiates
- Map each need to a style using the matrix — start from the need column, not the style you used last time
- For every webhook, make the receiver idempotent and add a reconciliation pull as the safety net
- For every polling loop, add backoff and a cursor or conditional request to bound load
- Flag any synchronous call that waits on a vendor-originated or long-running result and re-style it
- Record the chosen style per integration in the inventory so the decision is visible, not implicit