Can I use REST API if the site is protected with .htpasswd

You have to supply basic auth headers like below :

curl -D- \
   -X GET \
   -H "Authorization: Basic xxxxyyyzzz" \
   -H "Content-Type: application/json" \
   "https://your-domain.com/rest/api/v1"

“xxxxyyyzzz” is the username:password base64 encoded

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)