With respect to an API, I have used the BrainXML format to successfully load and update TheBrain. There is some documentation around but I can't lay my hands on it currently. I have created some but it isn't really ready for prime time sharing.
The structure is very logical. Pretty much EVERYTHING is a thought (except NOTES), even LINKS are thoughts, which is why they can have properties like thoughts.
Export a simple brain and follow the pointer. Look at the properties like the A and B links in a link.
Let me know if you are interested in my notes.