Views Rest Export and sending page numbers in it's response I have a paginated views using "rest export" and I'm using it to show that data on mobile app, everything works fine, but I want to know how many pages exist on that endpoint to show page numbers in my app.

I know I can alter the view programmatically, but I'm asking if there is a simple solution to achieve this.

This is the view settings page.
As of now there is no way to display total page count in views rest export. But you can get total pages, current page, items per page and total number of items using new custom style in your custom module which extends existing Serializer class as shown below:

&lt;?php

namespace Drupal\custom_module\Plugin\views\style;

use Drupal\rest\Plugin\views\style\Serializer;

/**
 * The style plugin for serialized output formats.
 *
 * @ingroup views_style_plugins
 *
 * @ViewsStyle(
 *   id = "custom_serializer",
 *   title = @Translation("Custom serializer"),
 *   help = @Translation("Serializes views row data and pager using the Serializer component."),
 *   display_types = {"data"}
 * )
 */
class CustomSerializer extends Serializer {

  /**
   * {@inheritdoc}
   */
  public function render() {
    $rows = [];
    // If the Data Entity row plugin is used, this will be an array of entities
    // which will pass through Serializer to one of the registered Normalizers,
    // which will transform it to arrays/scalars. If the Data field row plugin
    // is used, $rows will not contain objects and will pass directly to the
    // Encoder.
    foreach ($this-&gt;view-&gt;result as $row_index =&gt; $row) {
      $this-&gt;view-&gt;row_index = $row_index;
      $rows[] = $this-&gt;view-&gt;rowPlugin-&gt;render($row);
    }
    unset($this-&gt;view-&gt;row_index);

    // Get the content type configured in the display or fallback to the
    // default.
    if ((empty($this-&gt;view-&gt;live_preview))) {
      $content_type = $this-&gt;displayHandler-&gt;getContentType();
    }
    else {
      $content_type = !empty($this-&gt;options['formats']) ? reset($this-&gt;options['formats']) : 'json';
    }

    $pager = $this-&gt;view-&gt;pager;
    $class = get_class($pager);
    $current_page = $pager-&gt;getCurrentPage();
    $items_per_page = $pager-&gt;getItemsPerPage();
    $total_items = $pager-&gt;getTotalItems();
    $total_pages = 0;
    if(!in_array($class, ['Drupal\views\Plugin\views\pager\None', 'Drupal\views\Plugin\views\pager\Some'])){
      $total_pages = $pager-&gt;getPagerTotal();
    }

    $result = [
      'rows' =&gt; $rows,
      'pager' =&gt; [
        'current_page' =&gt; $current_page,
        'total_items' =&gt; $total_items,
        'total_pages' =&gt; $total_pages,
        'items_per_page' =&gt; $items_per_page,
      ],
    ];
    return $this-&gt;serializer-&gt;serialize($result, $content_type, ['views_style_plugin' =&gt; $this]);
  }

}


After adding above file clear drupal cache and edit the view. There you need to change the format from Serializer to Custom serializer.

In this style there is a little difference in the output. All rows are children of rows and pager information is part of pager. Sample output is as shown below:

{
   "rows":[
      {
         "title":"Test"
      },
      {
         "title":"Test"
      },
      {
         "title":"Title 5"
      },
      {
         "title":"Title 4"
      },
      {
         "title":"Title 3"
      }
   ],
   "pager":{
      "current_page":0,
      "total_items":6,
      "total_pages":2,
      "items_per_page":5
   }
}