Contentful logo

Contentful Community

How to get total count of related entries?

The situation is this: content type “Videos” has a field named “Teacher”, which is linked to content type “Teachers”. On other words, Videos has a many-to-one relationship with Teachers.

My question is how do we get the total number of Videos a Teacher have using the Content Delivery API.

Hi Wansaleh,

Are you trying to get the actual items or simply the number amount of teachers a given video entry has?

There’s not a way to solely provide the number of these linked items, but you could retrieve them all, and thus check the "total" property of your JSON response to check that amount.

You can learn more about this in the following link:

https://www.contentful.com/developers/docs/concepts/links