概要
以下の記事を参考に、DrupalのRESTful Viewsを使ってカスタムAPIを作成したので、その備忘録です。

Drupal:RESTful Viewsを使った瞬時にカスタムAPI構築! | 俺のDrupal(ドルーパル) | ORE NO DRUPAL
APIとはAPIとは、"Application Programming In
上記の記事の内容に加えて、ページネーションに関する設定方法も記載しています。
Viewsの作成
上記のサイトの通りに進めました。




ページネーションを許可する
以下の記事を参考にしました。
REST Export & Pagination
Hi all, Ive created a content type and created a view for the rest export of said content type. How pray tell do I get query parameters on rest exports with Drupal 8? Sort, offset, etc ie: http://d8.dev/api/publications?_format=hal_json&sort=desc&offset=1 Ive been looking for some solid information about this topic and have come up empty handed. I read on stack exchange that this is only possible via the Search API. Could someone give me a URI example of such a request? thnx.
ViewsのPagerを選択します。以下の通り、Fullとしました。Miniでも大丈夫そうでした。

「Allow user to control the number of items displayed in this view」と「Allow user to specify number of items skipped from beginning of this view.」にチェックを入れます。

結果、以下のようなパラメータが使えるようになりました。
/my_custom_api?items_per_page=10
/my_custom_api?items_per_page=10&offset=1
/my_custom_api?items_per_page=50
まとめ
カスタムAPIを作成する際の参考になりましたら幸いです。



コメント
…