Get a total or count of documents

Is there a way to grab the total number of documents? Preferably with query options? I’ve searched the documentation but seem to be coming up short. Everything I see has a max page limit of 100.

A general use case would be showing a total count of the posts within a category link, or calculating the total number of pages in a paginated list of posts (e.g. page 4 of 10).

Thanks for any insights, recommendations, or links to documentation I may have missed!

You can do it using totalCount with the GraphQL API, for example to grab the total number of documents of the type “Article”:

  allArticles {

Another example for getting the total number of documents of the type “Article” linked to a specific “Category” document (assuming the API ID of the content relationship field to link to category documents is category):

query {
  allArticles(where: {category:"XniT7xIAACgAk6zG"}) {

I hope this helps

1 Like

Perfect, thanks @nathanael! I’ll give that a go.

Hello @bryan, if you use the rest API by doing a request on all documents you will see in the result object return by the API a field called total_results_size, this is the total number of documents published in your API.

I hope this helps.

This issue has been closed due to inactivity.