How would you go about reading a .blend file? I mean all of a .blend file, not just the .obj information So, I'm well aware you can export a .blend file to a .obj and read that with pretty standard file i/o in c++. 

What I want to know is how to un-obfuscate a .blend file AND 

read in the information in the file as text or python code if possible
OR just know how a .blend file is structured or how blender stores data and compiles the .blend, and in what order like the data types and data structures stored

because I want to access the information for the materials used, the animations key frames, the composition of the scene, etc. 

EDIT: well so far I've found these useful sources 

Parsing a blend file by Raging Gazebo

The mystery of the blend file by Jeroen Bakker

plus, his breakdown of the SDNA for v2.56

And this from github for blender file reading linked by user2859

haven't found everything i'm looking but this was a lot of help so far. 

edit: there may have been important information one here, but now it's gone anyone know where the blender team moved it to?

edit: i gave up trying to parse the file just did an exporter in blender's python script, i got it to export the mesh data so far in an obj like format, now working on extracting the animation data. i'm using the api ref in mike's answer.
One way is to use Blender's bpy python module.

import bpy
dir(bpy.data)


As you will see from the output, you can access everything from object data to materials to screen layout. Here is the API for BPY.

The bpy module is typically built into Blender, but there are ways to compile it into a standalone Python module that you can load from a regular python file.



Someone has also taken the effort to write and open source a .blend reader in Java here http://homac.cakelab.org/projects/JavaBlend/index.html.