I've looked into this for my own projects. Nexus provides an API that will let you download mods from NXM links. For development purposes, you can use a personal API key from your Nexus account. Otherwise, they have an evaluation process to go through to gain access to their API. You can either have users generate an API key for your app or you can follow their awkward SSO process using WebSockets to get it from Nexus programmatically.
Also worth mentioning that anyone who uses Vortex can set up NXM Proxy to forward only RDR2 to LML to bypass the restriction of only being able to assign one application as an NXM link handler.