Accessing database' s content to Api without passing databases credentials

I have written an api script to get data from database and pass it to datatable. When working on another server, i wont be having access to database’s username and password. Is there any other way to do the same with any alternate option to access…something like frappe objects.

Any help will be hugely appreciated

Still waiting

If your api set to @frappe.whitelist(allow_guest=True) . It can be accessed from any servers without authentication (username and password), so everyone can access as well.

Any suggestion/hint to make connection with the help of objects

Help of objects? Sorry i don’t get it, can u explain?

Edit:
@frappe.whitelist(allow_guest=True)
def myapi():