Access to profile data from a custom script

I just wonder if it’s possible to access data displayed on the ‘profile’

There is no public API for this, but you can access app.stats, and get this: https://github.com/playcanvas/engine/blob/main/src/framework/stats.js

Note that this is a private API, and subject to change.

Note that all stats are available in profile build, but some also in the debug and final build, but not all.

Does it mean that I can’t get access if I build and download a project?
In that case, should I have to use a custom built engine?

First see if the data you need are being reported in your published build.
If not, you’d need to use profiling build of the engine instead of the final which gets added to your published build automatically. You don’t need to build it, but would need to download it and add to your project manually.