You can totally do that! (Wrap the pin in a plumber API). We actually have some examples that do this with a model "router" that chooses between two models at varying probabilities / weightedness (although this one doesn't use pins):
Another way to do it is definitely to interact with the pins directly via API. It is a bit tricky to do so, but you definitely can using Connect's Server API. I don't know that we have fantastic guidance on doing this, to be honest... I suspect it would be something along the lines of:
- Use an API Key with the "Authorization" header
- Make sure to set a "Content URL" / "Vanity URL" (this gives you a bit of protection in case you do want to change the pin at some point, replace with an API, etc.)
- Fetch the resource directly ( to get the latest )
- Fetching a specific version of the pin would likely require a bit more effort to figure out the particular "variant" URL
For example, here is a pin that is on our public demo server in .rds
format:
curl -I https://colorado.posit.co/rsc/bike-predict-r-model-metrics-pin/bike-predict-model-metrics.rds
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: must-revalidate, no-cache, max-age=0
Content-Length: 6601
Content-Type: application/x-gzip
Date: Tue, 07 Feb 2023 02:52:50 GMT
Last-Modified: Mon, 06 Feb 2023 20:56:59 GMT
Server: nginx/1.23.3
Set-Cookie: colorado-rsc=11c737a0ec77aab; Path=/; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=2592000
X-Content-Type-Options: nosniff
X-Correlation-Id: b8258b75-8b7a-4d7e-9332-6d8c0826f3ac
For authenticated content, you would need -H 'Authorization: Key my-api-key'
I would probably lean the API route for flexibility, and definitely recommend mapping out a diagram so people understand the flow of content!