Q:

How to access the list of volume grids using python?

I wanted to access the attributes imported with a vdb file but I have no idea how to do that.
Actually what I was trying to do is - In the attribute node in material for the vdb file I wanted to get it from the attributes loaded with the file, and for that suppose I would like to check if the temperature attribute is present or not if it is present fill that in attribute node and if not check for heat attribute and do the same for this also and if this is also not found a check for flames attribute.

Please can anyone tell me how to do this?

A:

Recommend use the python console to figure out the path, especially for new and undocumented properties. ObjectData.grids collection holds all the data (fields) you're searching for:
>>> C.object.data.grids.items()
[(0, bpy.data.volumes['Object_Name']...VolumeGrid),
 (1, bpy.data.volumes['Object_Name']...VolumeGrid),
 (2, bpy.data.volumes['Object_Name']...VolumeGrid),
 ...

To get the name for each field, use a for-loop:
>>> for field in C.object.data.grids:
...    print (field.name)
...
density
fuel
heat
temperature
vel.x
vel.y
vel.z 

Or a list comprehension to collect the names for your shader setup:
>>> [field.name for field in C.object.data.grids]
['density', 'fuel', 'heat', 'temperature', 'vel.x', 'vel.y', 'vel_z']

Example script on how to check whether there is a certain field (density, fuel, heat etc.):
import bpy

C = bpy.context

for field in C.object.data.grids:
    if field.name == "density":
        print ("Got density")
    else:
        print ("No density field")

