Overview

This is a memo about creating a custom API using Drupal’s RESTful Views, based on the following article.

https://acret.jp/drupal/node/434

In addition to the content of the above article, I also describe how to configure pagination.

Creating Views

I followed the instructions on the site mentioned above.

Enabling Pagination

I referenced the following article.

https://www.drupal.org/forum/support/post-installation/2015-12-04/rest-export-pagination

Select the Views Pager. I set it to Full as shown below. Mini also seemed to work fine.

Check “Allow user to control the number of items displayed in this view” and “Allow user to specify number of items skipped from beginning of this view.”

As a result, the following parameters became available.

/my_custom_api?items_per_page=10

/my_custom_api?items_per_page=10&offset=1

/my_custom_api?items_per_page=50

Summary

I hope this is helpful when creating custom APIs.