Advantage of writing REST APIs in cuba platform


I would like to know what is the advantage of writing REST APIs in cuba framework than outside.


Hi Sushma,

do you mean what the advantage is of using the CUBA REST API v2 compared to writing it on your own (e.g. in a custom Spring controller)?

Or is your question about the differences to write a custom REST API within the CUBA application (with a custom spring controller) compared to writing it in another application that will act as some kind of API-service?

Perhaps you can clarify a little bit what you want to know in detail.


Hi Mario,

I am looking for the first one. What the advantage is of using the CUBA REST API v2 compared to writing it on our own (e.g. in a custom Spring controller)?



generally speaking its the generic REST API v2 from CUBA a double-edged sword.

On the one hand side it comes for free. There is no need to implement a REST API via Spring, do custom JSON binding, integrating the security mechanisms (entity permissions etc.) and all this stuff. This means that it can be a heavy time saver, because it is already there.

On the other hand, since this API exposes all entities to the outside world, this also means that this API exposes internals of the system (like internal Entities e.g.). This normally becomes a problem in the mid-term. This might be a small one if you control the API clients on your side, or a big one if you cannot control the client, because they are not developed by yourself.

I’ve written down something that deals with this question quite some time ago. Perhaps you might want to take a look:

Bottom line:
When you more or less have an internal Integration use case, where you control both sides of the API, REST API v2 is totally worth it.
When you have a public API with requirements like proper versioning, a API model that differs a lot from your entity / DB model, then I would build something on my own. You can still use the REST API v2 in case you build an API service of some kind that internally calls it.

1 Like