Ideas for Vertex Color Scripting

I was wondering where to start looking into the script.
*For collapsing the vertex color layers by addition into the one channel for export.

Help to understand what API references I’m looking for in this case.
Is there anything related in Blender 3D…merge visible layers somewhere in the software already?

*I’ve baked vertex to texture and back again for testing.
*I’ve hooked up Cycles nodes where all channels can be combined and viewed by addition to the output!

import bpy
from mathutils import Color
# this example would be run from blender's text editor while a mesh object is selected
# the mesh object should have some vertex colors on it
ob = bpy.context.object
vcols =

vc_layer_count = len(vcols)#how many layers
vc_length = len(vcols[0].data)# all should be same length past this one

for i in range(vc_length):
    k = Color()# combine all the colors into this one and set the zero layer to its value at the end
    for j in range(vc_layer_count):
        c = vcols[j].data[i].color
        k.r += c.r * (1.0 / vc_layer_count)# this crap was a last minute idea i'm no wiz at color math
        k.g += c.g * (1.0 / vc_layer_count)# you should probably ask adobe how to do this section
        k.b += c.b * (1.0 / vc_layer_count)# with the math and stuff

    vcols[0].data[i].color = k

lol, thought it would be a short script! Looks good. Well guess I will try and learn some basics soon… thx…