It cannot be done. I mean, as m.ardito states, you can undo, or duplicate the text and keep a copy for backup, but converting to mesh is a one way, destructive action.
while not being able to turn it back into its original state, you can in fact grab every vertex and copy the material automatically. But you can never reside it back to its original state.
https://youtu.be/OEkrQGFqM10 should help a little
you'll probably want the vertex location command which can be found here How can I get vertex positions from a mesh? and basic location command is bpy.context.object.location.x bpy.context.object.location.y & bpy.context.object.location.z