Get Entry Title with API

Hello!

Is there a way to get fields marked as entry titles? Something like $entry->getEntryTitle()? (I’m using the PHP SDK.) I need to display all content entries by title in a dropdown menu, but my content models use semantic title fields. For example, a job content model would have a job title, and a blog content model would have a heading. These fields are marked as entry titles in Contentful. It would be super simple to just pull all entries and echo their specified entry title. However, I haven’t found a way to access it in the API response. Am I just missing something or is it actually not returned?

Thanks in advance!

Hi @nicole,

By reaching the entries endpoint, there is not a way to directly tag which of the fields should be the title of that entry. Instead, you’d have to send another request to the content type of that entry, and look for the displayField JSON property, such as text1 in the following example:

  "sys": {
        "space": {
          "sys": {
            "type": "Link",
            "linkType": "Space",
            "id": "e1doby2rss6y"
          }
        },
        "id": "texttext",
        "type": "ContentType",
        "createdAt": "2016-06-24T12:38:22.976Z",
        "updatedAt": "2016-06-29T12:51:19.802Z",
        "revision": 2
      },
      "displayField": "text1",
      "name": "texttext",
      "description": "",
      "fields": [
        {
          "id": "text1",
          "name": "text1",
          "type": "Text",
          "localized": false,
          "required": false,
          "disabled": false,
          "omitted": false
        },
....

Ohh okay, that helps! Thanks @gabriel!

Glad it helped, let us know if you have any other questions about this :smile: