Get total count of models in a query

Hi, This has to be a really common feature to get the count of all the fields in some meta tag on a paginated query.

For example, in a blog, I need to show page counts and links but I don’t have the information on the number of models. Can you please add the meta tag in the model query to give the information on the number of models that are available/published?

Hi Peeplee! We have heard this request before, and indeed have an internal ticket in our product backlog to add to our API, but no current timeframe. It looks like someone recently made a request to our external feature request board here Return the total amount of items in a model for | Ideas

I recommend upvoting this request, as our ideas board is a leading source of direction for our product team!

In the meantime, the best way to iterate over all entries in a model is to use limit and offset, as outlined in this post: What's the maximum limit allowed in a single content API call?

Try that out and see if it works for your use case!

hi @TimG, thanks for your heads up on this feature. Would you know if there is a workaround where it is not necessary to run multiple request to load all the entries? It doesn’t sound performant if I have a big amount of content and I want to render a simple pagination component.

I agree with @Peeplee that this has to be a really common feature. A must-have.


Hi @mstekl the best workaround using our API would be the one outlined in the linked post.

Another option would be to create a data model that is a count of how many content entries you have, and then use a webhook that updates the data model using our write API every time you publish / unpublish content. It would require some script setup, but once created would be relatively low / no maintenance.