Get data from the user persp view

How can I get data (in my case the euler rotation) from the user view in the viewport the cursor is hovering ?
Just to clear things up, I’m not talking about a camera object but the view you see when you’re out of the camera.

import bpy

for i in[0].areas:    # or[3].areas
    if i.type == 'VIEW_3D':
        s =

If the context is a VIEW_3D there’s no need to loop over the other areas…
one can go directly to bpy.context.region_data.

more to read:

Thank you guys ! The context version is what I needed. So I guess it can’t be Euler though ?

.view_matrix.to_euler() funtion

Thanks Secrop for your help on IRC.
The best-fitting command for my case was :


I used it in this add-on of which I just finished the first working version :