How to get the label of fields from API?

When accessing collection api, I get a field response with props as followed:

name: "average_weight"
type: "text"
localize: false
options: []

How do I get the field label name and info from the dashboard as well?

Looks like I can edit modules/Collections/Controller/RestApi.php to make it return additional fields. Still wondering if there is setting for this thou.

Interesting. I never noticed/missed the missing information - and I’m not sure, if it would be a useful default setting. 1. It could bloat the api request and 2. I use the label and the info fields to give clients detailed information about how to fill the content. For the frontend, I’m only interested in the field names…

You could write your own api endpoint:

  • Create a file /path/to/cockpit/config/api/collections/get/collection_name.php
  • copy/paste the content from modules/Collections/Controller/RestApi.php::get() with minor modifications
  • change the response with your needed field information
  • call the api like before