Get Space page hierarchy using the REST api

We are looking into using the REST api to create backups for all the content on our confluence cloud page. We would like this content to match the structure within confluence. Is there a simple 'view space structure' REST call to get the hierarchical structure of the pages within a space? 

At the moment the only way I can think of is recursively accessing the "/content/{id}/child/page" starting with the space root page until it returns an empty list. However this could end up being a ridiculous number of requests. 

Thanks for your help and I'll be happy to clarify anything. 

 

 

1 answer

Hi Andrew,

I think that if you use the space content API rest point(with depth=all) and expand the ancestors you will be able to collect the structure in one call

Regards,

Peter

Thanks for your help Peter. Perhaps I've not been setting up the pages correctly but my ancestors entry appears blank: 

 

_expandable: {
...
	ancestors: "",
...
}

 

I can get the descendants though of each page returned by doing:

expand=descendants.page

Unsure if this is the best of doing it but it seems to work! 

 

Thanks for your help again,

 

Andrew

 

 

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

915 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you