The versioning of notebooks is awesome. I’m wondering if there is an easy way to get the version number of a notebook from the UI? I see that I can get it from the notebook module code, but that’s a bit of a hassle. Also, if this is the only way, I’m not sure how I am intended to get version numbers for other people’s (public) notebooks, since I can’t get their module code via the UI?
No UI version, but you can retrieve it from the (undocumented) Observable API.
For example:
https://api.observablehq.com/document/@mbostock/five-minute-introduction
has the version number 344
.
You could also get a specific version by appending @versionnum
to the end. So if we wanted version 343 of the example above:
https://api.observablehq.com/document/@mbostock/five-minute-introduction@343
However, since it’s undocumented, I’m not sure how long this will be supported for, and there’s no way to see all the version numbers you have permission to access (e.g. @100 for the notebook above will give a 404).
Ah didn’t know the api endpoint, that’s good to know, thanks! Hopefully it’ll get added to the UI in some form soon.
@jflatow — (Although we intend to expose versions in some useful way soon …) I’d love to hear what you’re looking for the version number for? Are you manually versioning your imports?
import {cell} from "@jflatow/cool-notebook@42"
Yes this would be the use case - I am using some of my notebooks as libraries and wondering how to keep dependent notebooks from breaking if I change the APIs underneath. I’m also thinking about security - if I rely on someone else’s notebook in a notebook with sensitive data or in some restricted environment, how can I know that I’ve seen/verified the code that will be running on my page? It’s nice if I can trust observable that the import is immutable for a given version - which is my understanding of how this does/will work.
Yes. Notebooks at a given version are immutable — and our plan (although it’s not at the top of the feature priority list just yet) is to implement import pinning, where the version of the notebook or module you import is the version you’ll get in that notebook from that point onwards … unless you explicitly refresh the import to the latest version.
So hopefully in the reasonably near future — you won’t need to be digging around for version numbers for this particular reason, at least…
This notebook offers some helpers for version pinning, and for providing pinned import examples: Version Pinning for Notebooks / Fabian Iwand | Observable
Your notebook has been incredibly helpful! Here’s a fork that adds a few features:
- applies a regex to the
preview_name
input to parse full observablehq.com URLs (hopefully it’s correct, seenbMatch
), - a gadget to create a pinned compare link from two notebook names / URLs,
- support for passing in inputs via the query string: using nb, and nb2:
https://beta.observablehq.com/d/266a02d4ca20abc2?nb2=https://beta.observablehq.com/d/266a02d4ca20abc2&nb=https://beta.observablehq.com/@mootari/notebook-data
,
or using compare:https://beta.observablehq.com/d/266a02d4ca20abc2?compare=https://beta.observablehq.com/compare/55bed46f68a80641@361...266a02d4ca20abc2
.