Get RNA data path of property

Using the Copy Data Path (bpy.ops.ui.copy_data_path_button) operator, one can acquire the RNA data path of a specific property in the GUI. How can I accomplish something similar via the Blender API in python?

For anyone else wondering what the answer is, I was simply looking for the path_from_id() function for bpy_struct objects.