I want my website to connect to the database (MySQL) without using requests if possible.
If it is necessary to use requests, then how should I implement it, so that only the scripts in the
page can make requests to the server and not the user (If he/she gets the link to the API).
Thanks in advance.
Welcome to Stack Overflow. It sounds like you want your web page, displaying in your user's browser, to display data from your MySQL database.
So, you will have three networked programs.
The browser necessarily must initiate requests to the web server. There's no way for the web server to initiate requests to the browser. The web doesn't work that way. Never has. Never will.
The browser cannot interact directly with MySQL. It must go through the web server to do that.
Your web server, upon receiving requests from the browser, looks up what it needs from MySQL, then sends responses back to the browser.
So it's not possible to do what you want without requests.
It is possible to implement a system where the browser sends a request to your web server, and then the web server can send repeated messages to the browser using a data channel set up by that request. It's called WebSockets. A good way to use WebSockets is with socket.io. You can find code for browsers and for nodejs to set this up. It works nicely. Well-known apps like Slack use WebSockets.
But, with respect, you'll have a much easier time coding and debugging socket.io or other WebSocket code if you start with a good understanding of the basics of browser - webserver - MySQL networking. You may wish to do some reading about that first.