swh.web.api.views.content module#
- class swh.web.api.views.content.ContentRawQuerySerializer(*args, **kwargs)[source]#
- Bases: - Serializer- Content Raw query parameters serializer. - When a field is instantiated, we store the arguments that were used, so that we can present a helpful representation of the object. 
- 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,- sha256or- 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:
- Content-Type – this depends on Accept header of request 
 
- Status Codes:
- 200 OK – no error 
- 400 Bad Request – an invalid hash_type or hash has been provided 
- 404 Not Found – requested content cannot be found in the archive 
 
 - 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,- sha256or- 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:
- Content-Type – this depends on Accept header of request 
 
- Status Codes:
- 200 OK – no error 
- 400 Bad Request – an invalid hash_type or hash has been provided 
- 404 Not Found – requested content cannot be found in the archive 
 
 - 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,- sha256or- 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:
- Content-Type – this depends on Accept header of request 
 
- Status Codes:
- 200 OK – no error 
- 400 Bad Request – an invalid hash_type or hash has been provided 
- 404 Not Found – requested content cannot be found in the archive 
 
 - Example: - https://archive.softwareheritage.org/api/1/content/sha1:dc2830a9e72f23c1dfebef4413003221baa5fb62/license/ 
 
- swh.web.api.views.content.api_content_raw(request: Request, q: str, validated_query_params: dict[str, 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,- sha256or- 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:
- Content-Type – application/octet-stream 
 
- Status Codes:
- 200 OK – no error 
- 400 Bad Request – an invalid hash_type or hash has been provided 
- 404 Not Found – requested content cannot be found in the archive 
 
 - 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:
- Content-Type – this depends on Accept header of request 
 
- 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:
- 200 OK – no error 
- 400 Bad Request – an invalid sha1 has been provided 
 
 - 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,- sha256or- 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:
- Content-Type – this depends on Accept header of request 
 
- Response JSON Object:
- checksums (object) – object holding the computed checksum values for the requested content 
- data_url (string) – link to - GET /api/1/content/[(hash_type):](hash)/raw/for downloading the content raw bytes
- filetype_url (string) – link to - GET /api/1/content/[(hash_type):](hash)/filetype/for getting information about the content MIME type
- language_url (string) – link to - GET /api/1/content/[(hash_type):](hash)/language/for getting information about the programming language used in the content
- length (number) – length of the content in bytes 
- license_url (string) – link to - GET /api/1/content/[(hash_type):](hash)/license/for getting information about the license of the content
 
- Status Codes:
- 200 OK – no error 
- 400 Bad Request – an invalid hash_type or hash has been provided 
- 404 Not Found – requested content cannot be found in the archive 
 
 - Example: - https://archive.softwareheritage.org/api/1/content/sha1_git:fe95a46679d128ff167b7c55df5d02356c5a1ae1/