Getting the Confluence page count

How to determine the number of pages in the source Confluence?

The number of pages directly correlates with migration effort and times. This is why it’s a must to determine the number of pages in Confluence in one of the early phases of your Confluence to SharePoint migration project.

There are different approaches to getting the Confluence page count, described in the following sections.

Getting the page count from the database via SQL

Pro:

  • returns a guaranteed accurate page count

Contra:

  • needs permission to run SQL queries on the Confluence database
  • does not work with Confluence Cloud

Connect to the Confluence database and run the following SQL query:

select count(*) from content where (contenttype='PAGE' or contenttype='BLOGPOST') and prevver is null and content_status='current';

Note: Depending on the type of database the SQL query syntax might vary.

Getting the page count from the REST API

Pro:

  • easiest option, can be run in any browser
  • works in Confluence Cloud

Contra:

  • needs an account that is member of the confluence-administrators group
  • yields an inaccurate page count if user has too low restrictive permission level
  • does not work if Confluence search is broken or the search index is outdated

Copy the following search URL and replace confluencebaseurl with your Confluence’s base URL:

<confluencebaseurl>/rest/api/search?cql=type IN (blogpost, page)&limit=0

If you typically open Confluence at https://confluence.contoso.com the search URL would look like this:

https://confluence.contoso.com/rest/api/search?cql=type IN (blogpost, page)&limit=0

Open a browser, navigate to Confluence and log in.

Copy above search URL to the address bar of the browser you logged into Confluence with, and press the Return key to load the result.

The browser should now show text like this:

{"results":[],"start":0,"limit":0,"size":0,"totalSize":39348,"cqlQuery":"type IN (blogpost, page)","searchDuration":55,"_links":{"base":"https://confluence.contoso.com","context":""}}

The totalSize number is the page count, here: 39,348.

Third-party solutions

Let me know which third-party solutions you’d recommend: Get in touch.

Last modified September 18, 2023