open a app direct from package name using nodejs or php

generate a link which contain package name of the app that will open direct app if it is already installed on mobile means direct launch app and if it is not installed than option install from play store using nodejs or php

i have try https://play.google.com/store/apps/details?id=com.example.app but it is redirect to play store if app is installed i want that direct open app if i click on link