API or DIRECT DB?

I prefer JSON-RPC to REST because it’s protocol agnostic - HTTP, WebSockets or pure TCP.

I like to include a “service” member as well as the “method” as detailed here, it helps with routing and keeping related methods together.

So an example request might look like this:

{
"id": "abc", // your choice of id
"service": "seaCargo", // similar to a namespace
"method": "shipLocation", // the function to call
"params": ["Seago Bremerhaven"] // the arguments to pass to the function
}

And an example response:

{
"id": "abc", // for matching the response to a request
"error": null,
"result": {"longitude":1.3511000,"latitude":51.9637500}
}