C#C
C#3y ago
Core

Design REST API to request certain fields

Hello, this is a generic question

If a model has six fields, but as a response you only want to include four, a DTO would be used. This means that the
GET /users
request would contain a list of users, each with four fields.

Instead of
GET /users
, should the request URL be
GET /users?fields=name,username,etc
in this scenario?

I am wondering if this is used in real-life scenarios when the consumer of the API is a SPA.
Was this page helpful?