What is the difference between REST (Representational State Transfer) and RPC (Remote Procedure Call)?

RPC (Remote Procedure Call) is action-oriented. You’re essentially calling functions on a remote server as if they were local functions. For example, you might have endpoints like createUser(), deleteUser(), updateUserEmail(). Each endpoint does a specific thing - it’s very verb-focused. When you make an RPC call, you’re saying “do this action.”

REST (Representational State Transfer) is resource-oriented. Instead of thinking about actions, you think about resources (like users, posts, orders) and use HTTP methods to manipulate them. So you’d have a /users endpoint, and you’d use POST to create, DELETE to remove, PUT/PATCH to update. The same URL can handle different operations depending on the HTTP verb used.

In practical terms, an RPC API might look like:

  • POST /createUser
  • POST /deleteUser
  • POST /getUserById

While a REST API would be:

  • POST /users (create)
  • DELETE /users/123 (delete)
  • GET /users/123 (retrieve)

RPC tends to be more flexible and can be more intuitive when you have operations that don’t map cleanly to CRUD operations - like “sendEmail” or “calculateShippingCost”. REST forces you to think about everything as resources, which can sometimes feel awkward for actions.

REST has the advantage of being more standardized and cacheable (thanks to HTTP semantics), and it often leads to more consistent API designs. RPC implementations like gRPC can be more performant and offer features like bi-directional streaming.