programmatically retrieve frozen urls for CRAN from packagemanager.rstudio.com

Is there a way via script to retrieve the frozen URL of CRAN repo when given a date? Interactively in rspm's setup page this works but I need to do that via script given a date and maybe more for binary package url.

If you want to retrieve packages by date, as opposed to by version number, you can use the MRAN time machine:

options(repos=c(CRAN="https://mran.microsoft.com/snapshot/yyyy-mm-dd"))

Fill in yyyy-mm-dd with the date you're after.

Good point Hong,
microsoft's MRAN offers this feature. Still I am wondering whether RSPM also can somehow do it.

Take a look at RStudio Package Manager - there you can select any snapshot available there by clicking on any date in the calendar which will lead to an URL like
https://packagemanager.rstudio.com/cran/2021-09-21. Please also make note of the "Lock Package Data" feature.

Well Michael,
I need without human action the latest CRAN snapshot identified. Is there any chance to replace clicking on a date by some call to an API or so?

You may be aware of the Swagger API but this is currently in 0.0.1-alpha version and by far not able to meet your requirements.

I wonder what is the background for this request, especially why you cannot use /cran/latest ? We definitely can look into getting the necessary API calls exposed to RSPM once we understand the intent etc...

Happy to follow-up offline as well.