Why should I use include?


#1

Hi,

I’m currently building an API following the jsonApi spec and I’m struggle with the include keyword.
What’s the differences between getting related ressources using the include keyword and getting related related ressources following the relationships links.


#2

The basic tradeoff is:

  • If you use include, you only make one request, but your response is
    bigger.
  • If you don’t use include, you make multiple requests, but each response
    is smaller.

Whichever is better is up to you, and may even vary within a single
application!

Hope that helps.


#3

That helps ^^, thanks a lot.