Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence API - get page content from historical versions

Chris P.
Contributor
June 5, 2020

Use-Case:  I would like to pull the HTML body-content from different "versions" of the same confluence page for comparison.

This is to associate the individual who made a specific change said Confluence-page.

 

Using the Confluence API "Get content version":

https://developer.atlassian.com/cloud/confluence/rest/#api-api-content-id-version-versionNumber-get 

 

I am able to get all the historical information that I need (Updated by {username}, Date-Time of update, etc), EXCEPT the actual content / body (unless I'm missing it somewhere in one of the expanded sub-branches).

 

Via the regular Confluence WebUI, you can actually see all the page version, for example:

https://You_Company_Name.atlassian.net/wiki/pages/viewpage.action?pageId=123456789&pageVersion=21

>  but hoping there's a way to pull this HTML body down via the API

Searching around, there is mention in older versions of Confluence API pulling the content using the flag:

Status=historical

 

Here are some folks that have mentioned using the API with this flag:

===

1)

https://community.developer.atlassian.com/t/confluence-5-7-rest-api-get-content-get-many-versions/24237

2)

https://community.atlassian.com/t5/Answers-Developer-Questions/Is-fetching-of-previous-versions-of-a-wiki-page-really-not/qaq-p/538647

===

 

But on the Confluence API site, when  reading through the suggesting parameters for "Get content":

https://developer.atlassian.com/cloud/confluence/rest/#api-api-content-get

...  It mentions that:

"...  Note, the historical status is currently not supported..."

 

Does anyone know a way to pull the HTML body of historical versions of a Confluence page using the API?

 

 

1 answer

1 accepted

2 votes
Answer accepted
Chris P.
Contributor
June 7, 2020

Hi everyone,  I was able to find the API call where I can grab the HTML of previous versions, and compare to current version:

Previous version(s):

https://YOU_COMPANY_NAME.atlassian.net/wiki/rest/api/content/{page id}/version/{version number}?limit=10&expand=collaborators,content.body.storage

 

Which I can compare to the current version by calling:

 

https://YOU_COMPANY_NAME.atlassian.net/wiki/rest/api/content?title={YOU_PAGE_NAME}&expand=body.storage,version

 

from where I pullout the [value] field from each JSON payload responses.

 

Hope this helps folks.

Andrey Tetyuev April 28, 2025

Note: in case someone tries to use the accepted solution and receives error code 404 - it could be that the path to version is quite different, e.g.:

https://YOUR_SERVER_PATH/rest/experimental/content/{page_id}/version/{version_number}?...

Example:

https://my_server.com/rest/experimental/content/123456789/version/1?expand=metadata.labels,version,history,space,body.storage

To get the correct path in your case, you could open the current page-content with expanding its history and check there the REST API links to previous versions:

https://YOUR_SERVER_PATH/rest/api/content/{page_id}?expand=history.previousVersion

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events