swh.web.api.views.content module#

swh.web.api.views.content.api_content_filetype(request: Request, q: str)[source]#
GET /api/1/content/[(hash_type):](hash)/filetype/#

Get information about the detected MIME type of a content object.

Parameters:
  • hash_type (string) – optional parameter specifying which hashing algorithm has been used to compute the content checksum. It can be either sha1, sha1_git, sha256 or blake2s256. If that parameter is not provided, it is assumed that the hashing algorithm used is sha1.

  • hash (string) – hexadecimal representation of the checksum value computed with the specified hashing algorithm.

Response JSON Object:
  • content_url (object) – link to GET /api/1/content/[(hash_type):](hash)/ for getting information about the content

  • encoding (string) – the detected content encoding

  • id (string) – the sha1 identifier of the content

  • mimetype (string) – the detected MIME type of the content

  • tool (object) – information about the tool used to detect the content filetype

Request Headers:
  • Accept – the requested response content type, either application/json (default) or application/yaml

Response Headers:
Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/sha1:dc2830a9e72f23c1dfebef4413003221baa5fb62/filetype/
swh.web.api.views.content.api_content_language(request: Request, q: str)[source]#
GET /api/1/content/[(hash_type):](hash)/language/#

Get information about the programming language used in a content object.

Note: this endpoint currently returns no data.

Parameters:
  • hash_type (string) – optional parameter specifying which hashing algorithm has been used to compute the content checksum. It can be either sha1, sha1_git, sha256 or blake2s256. If that parameter is not provided, it is assumed that the hashing algorithm used is sha1.

  • hash (string) – hexadecimal representation of the checksum value computed with the specified hashing algorithm.

Response JSON Object:
  • content_url (object) – link to GET /api/1/content/[(hash_type):](hash)/ for getting information about the content

  • id (string) – the sha1 identifier of the content

  • lang (string) – the detected programming language if any

  • tool (object) – information about the tool used to detect the programming language

Request Headers:
  • Accept – the requested response content type, either application/json (default) or application/yaml

Response Headers:
Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/sha1:dc2830a9e72f23c1dfebef4413003221baa5fb62/language/
swh.web.api.views.content.api_content_license(request: Request, q: str)[source]#
GET /api/1/content/[(hash_type):](hash)/license/#

Get information about the license of a content object.

Parameters:
  • hash_type (string) – optional parameter specifying which hashing algorithm has been used to compute the content checksum. It can be either sha1, sha1_git, sha256 or blake2s256. If that parameter is not provided, it is assumed that the hashing algorithm used is sha1.

  • hash (string) – hexadecimal representation of the checksum value computed with the specified hashing algorithm.

Response JSON Object:
  • content_url (object) – link to GET /api/1/content/[(hash_type):](hash)/ for getting information about the content

  • id (string) – the sha1 identifier of the content

  • licenses (array) – array of strings containing the detected license names

  • tool (object) – information about the tool used to detect the license

Request Headers:
  • Accept – the requested response content type, either application/json (default) or application/yaml

Response Headers:
Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/sha1:dc2830a9e72f23c1dfebef4413003221baa5fb62/license/
swh.web.api.views.content.api_content_raw(request: Request, q: str)[source]#
GET /api/1/content/[(hash_type):](hash)/raw/#

Get the raw content of a content object (aka a “blob”), as a byte sequence.

Parameters:
  • hash_type (string) – optional parameter specifying which hashing algorithm has been used to compute the content checksum. It can be either sha1, sha1_git, sha256 or blake2s256. If that parameter is not provided, it is assumed that the hashing algorithm used is sha1.

  • hash (string) – hexadecimal representation of the checksum value computed with the specified hashing algorithm.

Query Parameters:
  • filename (string) – if provided, the downloaded content will get that filename

Response Headers:
Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/sha1:dc2830a9e72f23c1dfebef4413003221baa5fb62/raw/
swh.web.api.views.content.api_check_content_known(request: Request, q: str | None = None)[source]#
GET /api/1/content/known/(sha1)[,(sha1), ...,(sha1)]/#

Check whether some content(s) (aka “blob(s)”) is present in the archive based on its sha1 checksum.

Parameters:
  • sha1 (string) – hexadecimal representation of the sha1 checksum value for the content to check existence. Multiple values can be provided separated by ‘,’.

Request Headers:
  • Accept – the requested response content type, either application/json (default) or application/yaml

Response Headers:
Response JSON Object:
  • search_res (array) – array holding the search result for each provided sha1

  • search_stats (object) – some statistics regarding the number of sha1 provided and the percentage of those found in the archive

Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/known/dc2830a9e72f23c1dfebef4413003221baa5fb62,0c3f19cb47ebfbe643fb19fa94c874d18fa62d12/
swh.web.api.views.content.api_content_metadata(request: Request, q: str)[source]#
GET /api/1/content/[(hash_type):](hash)/#

Get information about a content (aka a “blob”) object. In the archive, a content object is identified based on checksum values computed using various hashing algorithms.

Parameters:
  • hash_type (string) – optional parameter specifying which hashing algorithm has been used to compute the content checksum. It can be either sha1, sha1_git, sha256 or blake2s256. If that parameter is not provided, it is assumed that the hashing algorithm used is sha1.

  • hash (string) – hexadecimal representation of the checksum value computed with the specified hashing algorithm.

Request Headers:
  • Accept – the requested response content type, either application/json (default) or application/yaml

Response Headers:
Response JSON Object:
Status Codes:

Example:

https://archive.softwareheritage.org/api/1/content/sha1_git:fe95a46679d128ff167b7c55df5d02356c5a1ae1/