Search code examples
restdatamodel

Manage data transfer in REST Architecture (Interface)


I'm working on my first client-server project and using REST. So my question is where and how do I handle the data.

Options:

  1. Define a datamodel and share it to the server and client. So I could you use JSON and object transfering, but each change of the datamodel requires also possible changes in the server and client implementation.
  2. Simply transfer the data as basic data types (strings, boolean etc.). So only a datamodel is required in the client.

What do you recommend?


Solution

  • As you want to develop REST APIs and REST evolves around resource representations so first option (define data model) is way to go.

    Note that all data model changes will not break the APIs and thus client implementations. Only when you re-structure your resource representation OR you take out one of attribute from model - that's when you will need to version your APIs.