Reading:
Alternatives to REST API in microservices

Alternatives to REST API in microservices

Metamug
Alternatives to REST API in microservices

REST APIs are a good way of designing and implementing microservices. There may be better alternatives to REST APIs in certain situations. Let us look into the alternatives to REST APIs. In our list we will stick to HTTP application layer technologies and not recommend using TCP/IP or RMI-based socket communications.

GraphQL

Graphql focuses on data instead of resources and operations to be performed on the resources. You can fetch different sets of data with filters applied using Graphql with a single POSt method. In REST different endpoints are needed to gather information across multiple HTTP calls, minimizing API calls.

GraphQL solves the N+1 Problem

REST APIs similar to ORM when requested for a resource may only retrieve information about that resource. Additional requests need to be made to load the remaining set of resources. (i.e. Child nodes)

JSON RPC.

JSON RPC is an HTTP-based remote procedural call. Just like conventional RPC, json-rpc sends the procedure to be executed on the server along with arguments if any. JSON -RPC is used by bitcoin nodes to fetch block information and to perform other operations on the blockchain network.

The below example is a JSON-RPC

{
   "jsonrpc":"1.0",
   "id":"curltest",
   "method":"getblock",
   "params":[
      "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"
   ]
}

The above json payload can be sent as curl request.

curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblock", "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/


Icon For Arrow-up
Comments

Post a comment