Best practice for getting the number of children nodes

WaltzKingWaltzKing Beginner grinnerPosts: 3Registered Users Beginner grinner
I have an application where in a couple of places I need to enumerate through all of the children of a node looking for a particular child, based on some property of the child (in one case the child's name and in another case the child's URI). Is there a "best practice" way of making sure I iterate through _all_ of the children? The reason I ask is that I've noticed that fetching the children of a node has defaults on the number of children returned - 100 in the case of nodes that are images and 10 in the case of nodes that are galleries. Alternatively, is there a way of finding the desired child node directly without the iteration?

Comments

  • gabbiegabbie SmugPM Posts: 61Registered Users, SmugMug Product Team SmugMug Employee

    Hi there!

    So it sounds like you're trying to figure out the best way to find a particular album or image within an album given information like the name or URI, is that correct?

    One thing to note is that when we're returning the children of a node, we paginate the results. So as you've discovered, for a large set of children, we would break them up and only return the first 10/100, but we also include information so that you know there are more to access. Here is some of our documentation about pagination: https://api.smugmug.com/api/v2/doc/tutorial/paging.html

    Have you had a chance to look at expansions yet? Depending on your use case, this would be a helpful tool to eliminate some of the hassle getting the precise information that you need: https://api.smugmug.com/api/v2/doc/advanced/expansions.html

    gabbie
    SmugMug Product Manager
Sign In or Register to comment.