Is there any way to alter the response of JSON API module? I am using JSON API module to expose data using REST API. I want to alter its response. I am trying to altering it using hook_ENTITY_TYPE_load. If I change any existing property it shows the updated value. But if I try to add custom property it doesn't show the custom property in response. The two hooks I used are below:

function my_custom_entity_type_alter(array &amp;$entity_types) {
  $entity_types['node']-&gt;set('flag_count', 10);
}

function my_custom_node_load($nodes) {
  foreach ($nodes as &amp;$node) {
    $node-&gt;flag_count = 10;
  }
}


I need to know if there is any possible way to alter the json api response with custom properties?
Please see how jsonapi_entity_base_field_info adds a computed property to the file entities. That should do.

If you don't want to create a virtual field, you can add a normalizer that only acts for that specific content type as a service. You'll need to use a higher priority than serializer.normalizer.entity.jsonapi (set to 21). Your custom normalizer can inherit from Drupal\jsonapi\Normalizer\ContentEntityNormalizer and add your custom stuff in getFields.