# Retrieving notebook version identifier

**URL:** <https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914>\
**Category:** Help\
**Created:** [June 23, 2018, 5:15pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914 "2018-06-23T17:15:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jflatow](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jflatow/32/3401_2.png) [@jflatow](https://talk.observablehq.com/u/jflatow)\
**Post date:** [June 23, 2018, 5:15pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/1 "2018-06-23T17:15:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![asg017](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/asg017/32/2159_2.png) [@asg017](https://talk.observablehq.com/u/asg017)\
**Post date:** [June 24, 2018, 4:49am UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/2 "2018-06-24T04:49:53Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![jflatow](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jflatow/32/3401_2.png) [@jflatow](https://talk.observablehq.com/u/jflatow)\
**Post date:** [June 24, 2018, 5:04am UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/3 "2018-06-24T05:04:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)\
**Post date:** [June 25, 2018, 5:02pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/4 "2018-06-25T17:02:50Z")

</div>

@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?

```auto
import {cell} from "@jflatow/cool-notebook@42"

```

---

<div class="post-metadata">

**Author:** ![jflatow](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jflatow/32/3401_2.png) [@jflatow](https://talk.observablehq.com/u/jflatow)\
**Post date:** [June 26, 2018, 1:39pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/5 "2018-06-26T13:39:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)\
**Post date:** [June 26, 2018, 5:04pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/6 "2018-06-26T17:04:28Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [November 18, 2018, 3:37am UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/7 "2018-11-18T03:37:55Z")

</div>

> [@jflatow](#):
>
> I am using some of my notebooks as libraries and wondering how to keep dependent notebooks from breaking if I change the APIs underneath

This notebook offers some helpers for version pinning, and for providing pinned import examples: [Version Pinning for Notebooks / Fabian Iwand | Observable](https://beta.observablehq.com/@mootari/notebook-data)

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [November 24, 2018, 3:47pm UTC](https://talk.observablehq.com/t/retrieving-notebook-version-identifier/914/8 "2018-11-24T15:47:17Z")

</div>

Your notebook has been incredibly helpful! [Here’s a fork](https://beta.observablehq.com/compare/55bed46f68a80641@361...266a02d4ca20abc2@467) that adds a few features:

- applies a regex to the `preview_name` input to parse full [observablehq.com](http://observablehq.com) URLs (hopefully it’s correct, see `nbMatch`),
- 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`](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`](https://beta.observablehq.com/d/266a02d4ca20abc2?compare=https://beta.observablehq.com/compare/55bed46f68a80641@361...266a02d4ca20abc2).
