Reading cluster content programmatically

I want to create a python or C# script that can be run from a GH file, that checks all the clusters in the file, and also iteratively opens each cluster and checks the clusters in it. AI gave me a first draft, but it did not provide a working solution for opening clusters and checking inside them.

The goal of this exercise: I want to automatically check if there is any cluster in the entire file (also nested on a deeper level) that is externally referenced. I want to convert all of those to internalised clusters before shipping to end users.

Is there a good API documentation available that I can use for stuff like this?

Any suggestions for the code ?

Thanks in advance !

You need reflection to access password-protected clusters. iirc the documented way is .Document() or something alike. You can check the definition of GH_Cluster class by object browser or definition peek in VS/VSC. Don’t always rely on vibe coding.