Skip to main content
Ahora la API REST está versionada. Para obtener más información, consulta "Acerca del control de versiones de la API".

Puntos de conexión de la API de REST para la lista de materiales de software (SBOM)

Usa la API REST para exportar la lista de materiales de software (SBOM) de un repositorio.

Si tienes al menos acceso de lectura al repositorio, puedes exportar el gráfico de dependencias del repositorio como una la lista de materiales de software (SBOM) compatible con SPDX, a través de la interfaz de usuario de GitHub o la API REST de GitHub. Para más información, consulta Exportación de una lista de materiales de software para el repositorio.

En este artículo se proporcionan detalles sobre el punto de conexión de API REST.

Export a software bill of materials (SBOM) for a repository.

Exports the software bill of materials (SBOM) for a repository in SPDX JSON format.

Tokens de acceso granulares para "Export a software bill of materials (SBOM) for a repository."

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Contents" repository permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "Export a software bill of materials (SBOM) for a repository."

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
owner string Obligatorio

The account owner of the repository. The name is not case sensitive.

repo string Obligatorio

The name of the repository without the .git extension. The name is not case sensitive.

Códigos de estado de respuesta HTTP para "Export a software bill of materials (SBOM) for a repository."

código de estadoDescripción
200

OK

403

Forbidden

404

Resource not found

Ejemplos de código para "Export a software bill of materials (SBOM) for a repository."

Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/repos/{owner}/{repo}/dependency-graph/sbom
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/dependency-graph/sbom

Response

Status: 200
{ "sbom": { "SPDXID": "SPDXRef-DOCUMENT", "spdxVersion": "SPDX-2.3", "creationInfo": { "created": "2021-09-01T00:00:00Z", "creators": [ "Tool: GitHub.com-Dependency-Graph" ] }, "name": "github/example", "dataLicense": "CC0-1.0", "documentNamespace": "https://spdx.org/spdxdocs/protobom/15e41dd2-f961-4f4d-b8dc-f8f57ad70d57", "packages": [ { "name": "rails", "SPDXID": "SPDXRef-Package", "versionInfo": "1.0.0", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "MIT", "licenseDeclared": "MIT", "copyrightText": "Copyright (c) 1985 GitHub.com", "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", "referenceLocator": "pkg:gem/rails@1.0.0" } ] }, { "name": "github/example", "SPDXID": "SPDXRef-Repository", "versionInfo": "main", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "externalRefs": [ { "referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl", "referenceLocator": "pkg:github/example@main" } ] } ], "relationships": [ { "relationshipType": "DEPENDS_ON", "spdxElementId": "SPDXRef-Repository", "relatedSpdxElement": "SPDXRef-Package" }, { "relationshipType": "DESCRIBES", "spdxElementId": "SPDXRef-DOCUMENT", "relatedSpdxElement": "SPDXRef-Repository" } ] } }

Fetch a software bill of materials (SBOM) for a repository.

Fetches a previously generated software bill of materials (SBOM) for a repository. When the SBOM is ready, the response is a 302 redirect to a temporary download URL for the SBOM in SPDX JSON format. The generated SBOM report may be retained for up to one week from the original request. The temporary download URL returned by this endpoint expires separately, and its expiry is set when the fetch request is made.

Tokens de acceso granulares para "Fetch a software bill of materials (SBOM) for a repository."

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Contents" repository permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "Fetch a software bill of materials (SBOM) for a repository."

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
owner string Obligatorio

The account owner of the repository. The name is not case sensitive.

repo string Obligatorio

The name of the repository without the .git extension. The name is not case sensitive.

sbom_uuid string Obligatorio

The unique identifier of the SBOM export.

Códigos de estado de respuesta HTTP para "Fetch a software bill of materials (SBOM) for a repository."

código de estadoDescripción
202

SBOM is still being processed, no content is returned.

302

Redirects to a temporary download URL for the completed SBOM.

403

Forbidden

404

Resource not found

Ejemplos de código para "Fetch a software bill of materials (SBOM) for a repository."

Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/repos/{owner}/{repo}/dependency-graph/sbom/fetch-report/{sbom_uuid}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/dependency-graph/sbom/fetch-report/SBOM_UUID

SBOM is still being processed, no content is returned.

Status: 202

Request generation of a software bill of materials (SBOM) for a repository.

Triggers a job to generate a software bill of materials (SBOM) for a repository in SPDX JSON format.

Tokens de acceso granulares para "Request generation of a software bill of materials (SBOM) for a repository."

Este punto de conexión funciona con los siguientes tipos de token pormenorizados:

El token pormenorizado debe tener el siguiente conjunto de permisos:

  • "Contents" repository permissions (read)

Este punto de conexión se puede usar sin autenticación o los permisos mencionados anteriormente si solo se solicitan recursos públicos.

Parámetros para "Request generation of a software bill of materials (SBOM) for a repository."

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
owner string Obligatorio

The account owner of the repository. The name is not case sensitive.

repo string Obligatorio

The name of the repository without the .git extension. The name is not case sensitive.

Códigos de estado de respuesta HTTP para "Request generation of a software bill of materials (SBOM) for a repository."

código de estadoDescripción
201

Created

403

Forbidden

404

Resource not found

Ejemplos de código para "Request generation of a software bill of materials (SBOM) for a repository."

Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/repos/{owner}/{repo}/dependency-graph/sbom/generate-report
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/repos/OWNER/REPO/dependency-graph/sbom/generate-report

Response

Status: 201
{ "sbom_url": "https://api.github.com/repos/github/example/dependency-graph/sbom/fetch-report/4bab1a7e-da63-4828-9488-44e0e01a7c1b" }