swhid is an OCaml library to work with persistent identifiers found in Software Heritage, also known as swhid. It provides:
Swhid_core.Object module)Swhid.Compute)Swhid.Download)swhid can be installed with opam:
opam install swhidIf you don't have opam, you can install it following the how to install opam guide.
If you can't or don't want to use opam, consult the opam file for build instructions.
let id = "swh:1:rev:db21f0afdb54c16b265754ca599869fda0ca4bfc"
let url =
match Swhid_core.Object.of_string id with
| Error e -> Error e
| Ok id -> Swhid.Download.revision id
let () =
match url with
| Error e -> Format.eprintf "can't get download URL: `%s`@." e
| Ok url ->
Format.printf "you can download the revision at the URL: `%s`@." urlFor more, have a look at the example folder, at the documentation or at the test suite.