You might be able to use Read gbXML Polyloop/Spider gbXML Viewer. I'm not sure what kind of API it has but it is open source so you can look at the code.