Description

Get information about directory objects. Directories are identified by sha1 checksums, compatible with Git directory identifiers. See swh.model.git_objects.directory_git_object in our data model module for details about how they are computed.

When given only a directory identifier, this endpoint returns information about the directory itself, returning its content (usually a list of directory entries). When given a directory identifier and a path, this endpoint returns information about the directory entry pointed by the relative path, starting path resolution from the given directory.

Request

GET https://archive.softwareheritage.org/api/1/directory/3efbcc80237ab7c3d4eb5bf31c893ca6de88e747/

Response

Body
[
    {
        "checksums": {
            "sha1": "0fc04e2a5b34d4d5ebae85de55e9e5b36c0a5185",
            "sha1_git": "c24578bc08d25c11337ab6ec1b99978f1fd57895",
            "sha256": "48e858c0a4eeeb2f9cb7feaff5cd19da9fef3a1cc8eb05f920f77f7e75474170"
        },
        "dir_id": "3efbcc80237ab7c3d4eb5bf31c893ca6de88e747",
        "length": 67,
        "name": "README",
        "perms": 33188,
        "status": "visible",
        "target": "c24578bc08d25c11337ab6ec1b99978f1fd57895",
        "target_url": "https://archive.softwareheritage.org/api/1/content/sha1_git:c24578bc08d25c11337ab6ec1b99978f1fd57895/",
        "type": "file"
    },
    {
        "checksums": {
            "sha1": "234d39c77e81f95406070892b092ed8bd26dad58",
            "sha1_git": "1069966a1876ed61a195aa2fefaa56340a483d95",
            "sha256": "1c64a55b791bfc3397f5d74bd820be8cee50303f20320cb7f815dbf4874bc626"
        },
        "dir_id": "3efbcc80237ab7c3d4eb5bf31c893ca6de88e747",
        "length": 4528,
        "name": "_freeze_importlib.c",
        "perms": 33188,
        "status": "visible",
        "target": "1069966a1876ed61a195aa2fefaa56340a483d95",
        "target_url": "https://archive.softwareheritage.org/api/1/content/sha1_git:1069966a1876ed61a195aa2fefaa56340a483d95/",
        "type": "file"
    },
    {
        "checksums": {
            "sha1": "daea90a46bc9a3daadc0699c40e8b9d4fa464a32",
            "sha1_git": "a68d4fa25f7cd05f8d112e6b0d286e64d7eef392",
            "sha256": "2de2f1122dd8c6402da4ab81e8b89fc52656ee848f0d3a7244f3d278b1094dd0"
        },
        "dir_id": "3efbcc80237ab7c3d4eb5bf31c893ca6de88e747",
        "length": 5093,
        "name": "_testembed.c",
        "perms": 33188,
        "status": "visible",
        "target": "a68d4fa25f7cd05f8d112e6b0d286e64d7eef392",
        "target_url": "https://archive.softwareheritage.org/api/1/content/sha1_git:a68d4fa25f7cd05f8d112e6b0d286e64d7eef392/",
        "type": "file"
    },
    {
        "checksums": {
            "sha1": "2255692f9fab72339ab11ee3364b1bf356ffbe7d",
            "sha1_git": "a7afbc774b3a55b01bec9ed41eed1a376a2c4232",
            "sha256": "b7863d8dddd4eb9cb6eaac07e1f8badf5ac971ff4616a64389fa58b13f3770a1"
        },
        "dir_id": "3efbcc80237ab7c3d4eb5bf31c893ca6de88e747",
        "length": 2155,
        "name": "python.c",
        "perms": 33188,
        "status": "visible",
        "target": "a7afbc774b3a55b01bec9ed41eed1a376a2c4232",
        "target_url": "https://archive.softwareheritage.org/api/1/content/sha1_git:a7afbc774b3a55b01bec9ed41eed1a376a2c4232/",
        "type": "file"
    }
]

URL Allowed Methods

https://archive.softwareheritage.org/api/1/directory/ (sha1_git) /[ (path) /]

GET, HEAD, OPTIONS

Arguments

sha1_git (string)

hexadecimal representation of the directory sha1_git identifier

path (string)

optional parameter to get information about the directory entry pointed by that relative path


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


Returns

array

an array of objects containing the following keys:

  • checksums (object): object holding the computed checksum values for a directory entry (only for file entries)

  • dir_id (string): sha1_git identifier of the requested directory

  • length (number): length of a directory entry in bytes (only for file entries) for getting information about the content MIME type

  • name (string): the directory entry name

  • perms (number): permissions for the directory entry

  • target (string): sha1_git identifier of the directory entry

  • target_url (string): link to /api/1/content/ or /api/1/directory/ depending on the directory entry type

  • type (string): the type of the directory entry, can be either dir, file or rev


HTTP status codes

200

no error

400

an invalid hash_type or hash has been provided

404

requested directory cannot be found in the archive


Examples

/api/1/directory/977fc4b98c0e85816348cebd3b12026407c368b6/
back to top