How to track the average time on page using the HTTP API?

how to track the average time on page using the HTTP API?
what parameters should I use when sending the data?

Use gt_ms — The amount of time it took the server to generate this action, in milliseconds. This value is used to process the Page speed report Avg. generation time column in the Page URL and Page Title reports, as well as a site wide running average of the speed of your server. Note: when using the JavaScript tracker this value is set to the ime for server to generate response + the time for client to download response.

see: Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

I’m sorry that I didn’t state the problem clearly. Actually, I want to track the time the user spend on the page(for example, the duration from entering the page to leaving the page) by HTTP API, not how fast my website is. Can I do this with HTTP API instead of JavaScript ? THANKS a lot!