Home > Blockchain >  Should a RESTful GET collection API return content of elements
Should a RESTful GET collection API return content of elements

Time:10-23

I have an entity stored in the backend which translates to the json format as,

{
  "id": 123,
  "name": "test",
  "key": "test1",
  "description": "",
  "models": [
    {
      content
    },
    {
      content
    }
  ]
}

So when i want to retrieve the list of elements using the api

GET /elements

Should i return the elements metadata only(id, name, descriptions) or should also include the content(models[])?

CodePudding user response:

Normally

GET /elements

would return a list of complete entities.

You could add another endpoint:

GET /elements/meta or GET /elements?mode=meta

which would return a List of the metadata only.

  • Related