title: Restful APIs: readonly / writeonly fields
body: <p>I have a conceptual question with restful apis. In my data model, I have countries and companies. </p>
  
  <p>Users of the api won't be able to create country objects. There are constant entries in the database for countries. They will be creating company objects, which have country as a field. So when creating a company, api expects a json like:</p>
  
  <pre><code>{
      'name': 'company name',
      'country': 5, // country id
      ...
  }
  </code></pre>
  
  <p>On the client side, when displaying a company, we also want to display its country. One approach to this is, after getting a company resource, we issue another get request to get the country object. But this approach is problematic performance-wise, especially on the pages we list multiple companies.</p>
  
  <p>Another approach would be to include country details in another field on get requests, like:</p>
  
  <pre><code>{
      'name': 'company name',
      'country': 5, // country id
      'country_details': {
          'name': 'USA',
          'phone_code': 1,
          'id': 5
      }
      ...
  }
  </code></pre>
  
  <p>I do not think that this is the correct approach either, as data representation is different for post and get requests for the same resource. Have any suggestions for this case?</p>