Get ID's of all published pages?
# help-with-umbraco
b
In Umbraco 13, is there an way, (possibly via the Content API?) to get a list of all published nodes? For example (1003,1008,1018,1019) etc.
s
I guess the biggest question is: why do you need all the IDs? But.. If you're talking about the Content Delivery API then, yeah sure, you can get all nodes, this takes the first 10
/umbraco/delivery/api/v2/content?skip=0&take=10
It will give you a
total
properties that tells you how many nodes there are in total, so you repeat the above and change the
skip
and
take
until you have all the nodes. IDs are stored as a GUID so you will get those back for each node.
b
Thanks Seb, We're looking at Headless to Static Site Generation (Gatbsy). Trying to figure out the best approach to let Gatbsy know which pages need building. Any tips / alternative thinking much appreciated 🙂
c
@bodie_37269 I would suggest taking a look at the new Webhooks introduced in Umbraco 13! With this and some infrastructure know-how you can hook into events like Content Published to rebuild just that specific piece of content in your Static site! 🙂 https://docs.umbraco.com/umbraco-cms/reference/webhooks
s
☝️
b
Thanks both. Not sure if I'm missing something here. The webhook lets Gatsby, or whichever service know that we want something to happen. However as far as I can see the webhook doesn't state which items need updating (by Gatbsy). 2 scenarios: 1) It's the first build so we need to build all pages. 2) It's an incremental build so we only need to publish a few pages. In this instance it's not always this simple, as the page just published might have a relationship that affects another page. For this we're looking at the Tracked Service feature. Webhooks won't solve this for us here as far as I understand (happy to be wrong!)
s
The webhook emits what has been updated
"Id": "c1922956-7855-4fa0-8f2c-7af149a92135"
- you can either do a full rebuild or send the webhook somewhere else with your own custom logic to decide what you want rebuilt.
b
Thanks Seb, that makes sense and was my understanding.
16 Views