Content#

GET /browse/content/[(algo_hash):](hash)/#

HTML view that displays a content identified by its hash value.

If the content to display is textual, it will be highlighted client-side if possible using highlightjs. In order for that operation to be performed, a programming language must first be associated to the content. The following procedure is used in order to find the language:

  1. First try to find a language from the content filename (provided as query parameter when navigating from a directory view).

  2. If no language has been found from the filename, try to find one from the content mime type. The mime type is retrieved from the content metadata stored in the archive or is computed server-side using Python magic module.

It is also possible to highlight specific lines of a textual content (not in terms of syntax highlighting but to emphasize some relevant content part) by either:

  • clicking on line numbers (holding shift to highlight a lines range)

  • using an url fragment in the form ‘#Ln’ or ‘#Lm-Ln’

When that view is called in the context of a navigation coming from a directory view, a breadcrumb will be displayed on top of the rendered content in order to easily navigate up to the associated root directory. In that case, the path query parameter will be used and filled with the path of the file relative to the root directory.

Parameters:
  • algo_hash (string) – optional parameter to indicate the algorithm used to compute the content checksum (can be either sha1, sha1_git, sha256 or blake2s256, default to sha1)

  • hash (string) – hexadecimal representation for the checksum from which to retrieve the associated content in the archive

Query Parameters:
  • path (string) – describe the path of the content relative to a root directory (used to add context aware navigation links when navigating from a directory view)

  • origin_url (string) – optional; specify the origin from which to retrieve the contnet.

  • snapshot (string) – optional; specify the snapshot from which to retrieve the contnet.

  • timestamp (string) – optional; an ISO 8601 datetime string to parse in order to find the closest visit

  • branch (string) – optional; specify the snapshot branch name from which to retrieve the content. HEAD branch will be used by default.

  • release (string) – optional; specify the snapshot release name from which to retrieve the content.

Status Codes:

Examples:

https://archive.softwareheritage.org/browse/content/sha1_git:f5d0b39a0cdddb91a31a537052b7d8d31a4aa79f/
https://archive.softwareheritage.org/browse/content/sha1_git:f5d0b39a0cdddb91a31a537052b7d8d31a4aa79f/#L23-L41
https://archive.softwareheritage.org/browse/content/blake2s256:1cc1e3124957c9be8a454c58e92eb925cf4aa9823984bd01451c5b7e0fee99d1/
https://archive.softwareheritage.org/browse/content/sha1:1cb1447c1c7ddc1b03eac88398e40bd914d46b62/
https://archive.softwareheritage.org/browse/content/sha256:8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903/
GET /browse/content/[(algo_hash):](hash)/raw/#

HTML view that produces a raw display of a content identified by its hash value.

The behaviour of that view depends on the mime type of the requested content. If the mime type is from the text family, the view will return a response whose content type is text/plain that will be rendered by the browser. If the mime type corresponds to an image format supported by browsers, it will be used as content type. Otherwise, the view will return a response whose content type is application/octet-stream and the browser will then offer to download the file.

In the context of a navigation coming from a directory view, the filename query parameter will be used in order to provide the real name of the file when one wants to save it locally.

Parameters:
  • algo_hash (string) – optional parameter to indicate the algorithm used to compute the content checksum (can be either sha1, sha1_git, sha256 or blake2s256, default to sha1)

  • hash (string) – hexadecimal representation for the checksum from which to retrieve the associated content in the archive

Query Parameters:
  • filename (string) – indicate the name of the file holding the requested content (used when one wants to save the content to a local file)

  • re_encode (boolean) – if true, re-encode content to UTF-8 header for HTTP response to the content’s mime type.

Status Codes:

Examples:

https://archive.softwareheritage.org/browse/content/sha1_git:f5d0b39a0cdddb91a31a537052b7d8d31a4aa79f/raw/?filename=LICENSE
https://archive.softwareheritage.org/browse/content/blake2s256:1cc1e3124957c9be8a454c58e92eb925cf4aa9823984bd01451c5b7e0fee99d1/raw/?filename=MAINTAINERS
https://archive.softwareheritage.org/browse/content/sha1:1cb1447c1c7ddc1b03eac88398e40bd914d46b62/raw/
https://archive.softwareheritage.org/browse/content/sha256:8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903/raw/?filename=COPYING
GET /browse/content/#

HTML view that displays a content identified by the query parameters. An origin URL, snapshot or revision must be provided along with a content path as query parameters.

Query Parameters:
  • path (string) – The path of the content relative to the root directory

  • origin_url (string) – optional; specify the origin from which to retrieve the contnet.

  • snapshot (string) – optional; specify the snapshot from which to retrieve the contnet.

  • timestamp (string) – optional; an ISO 8601 datetime string to parse in order to find the closest visit

  • branch (string) – optional; specify the snapshot branch name from which to retrieve the content. HEAD branch will be used by default.

  • release (string) – optional; specify the snapshot release name from which to retrieve the content.

Status Codes:
  • 200 OK – no error

  • 404 Not Found – path and/or the identifier is missing in the query parameters.

  • 404 Not Found – requested content cannot be found in the archive, or the provided content path does not exist from the origin root directory

Examples:

https://archive.softwareheritage.org/browse/content/?origin_url=https://github.com/python/cpython&path=.gitignore
https://archive.softwareheritage.org/browse/content/?snapshot=673156c31a876c5b99b2fe3e89615529de9a3c44&path=src/opengl/qglbuffer.h