Course contentsShow
← Software Engineering
Lesson 798 of 1,93325. RPC and GraphQL API DesignFree lesson

What is RPC and How It Differs from REST

Understanding Remote Procedure Call paradigm and its action-oriented approach versus REST's resource-oriented model.

What is RPC and How It Differs from REST

You'll learn: The fundamental difference between calling remote functions (RPC) and working with resources (REST).

Understanding RPC

RPC (Remote Procedure Call) is an API design paradigm where you expose methods or functions that clients can invoke remotely. When you make an RPC call, you're essentially saying "execute this action" — like calling a function in your own codebase, except it runs on a distant server.

Think of RPC like calling someone on the phone and asking them to do something specific: "Turn on the lights," "Calculate this total," or "Send this email." You're issuing commands.

The Core Difference: Actions vs Resources

While REST organizes APIs around resources (nouns like "users," "orders," "products"), RPC organizes around actions (verbs like "getUser," "createOrder," "calculateShipping").

REST Example (Resource-Oriented)

GET /users/123        # Retrieve a user resource
POST /orders          # Create a new order resource
DELETE /products/456  # Remove a product resource

RPC Example (Action-Oriented)

getUser(id: 123)
createOrder(data)
deleteProduct(id: 456)

In REST, you manipulate resources using standard HTTP verbs. In RPC, you call named procedures that describe what you want done. RPC APIs often use POST for everything, with the action name in the URL or request body.

When Does RPC Make Sense?

RPC shines when your API is truly about actions rather than resources — operations like "runReport," "processPayment," or "restartServer" that don't map cleanly to CRUD operations on resources.

Key Takeaway: RPC treats APIs as remote function calls focused on actions, while REST treats APIs as manipulations of resources — choose based on whether your domain is action-driven or resource-driven.