how to get camera exactly like in the z perspective view
Top view for camera has no translation or rotation.
See.
Align camera to view precisely and automatically, without manual fiddling
How to convert current view as camera?

Oops, realized after making gif q asked for perspective rather than ortho. ie don't change to ortho, however ortho is IMO may be a better way to make text look 2D.
In the cameras property boxes, can clear both location and rotation, to have the camera facing downwards.
Via shortcuts / menu with
AltG  Object &gt; Clear &gt; Clear Location
AltR  Object &gt; Clear &gt; Clear Rotation
Then move up in $z$ and set camera type to perespective
Here is a script to do this, moving the camera to 2 bu directly above origin.
import bpy

context = bpy.context
scene = context.scene
cam = scene.camera

cam.matrix_world.identity()
cam.data.type = 'PERSP'
cam.matrix_world.translation.z = 2