Points de terminaison d’API REST pour la nomenclature logicielle (SBOM)
Utilisez l’API REST pour exporter la nomenclature logicielle (SBOM) d’un référentiel.
Si vous disposez au moins d’un accès en lecture au dépôt, vous pouvez exporter les graphe des dépendances pour le dépôt en tant que nomenclature logicielle compatible SPDX (SBOM), via l’interface utilisateur de GitHub ou l’API REST GitHub. Pour plus d’informations, consultez « Exportation d’une nomenclature logicielle pour votre dépôt ».
Cet article fournit des détails sur le point de terminaison de l’API REST.
Remarque
GitHub Enterprise Server ne récupère pas les informations de licence pour les dépendances, et ne calcule pas les informations sur les dépendants, les référentiels et les packages qui dépendent d’un référentiel. Ces champs ne seront pas renseignés dans la réponse.
Export a software bill of materials (SBOM) for a repository.
Exports the software bill of materials (SBOM) for a repository in SPDX JSON format.
Fine-grained access tokens for "Export a software bill of materials (SBOM) for a repository."
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- "Contents" repository permissions (read)
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
Paramètres pour «Export a software bill of materials (SBOM) for a repository. »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
owner string RequisThe account owner of the repository. The name is not case sensitive. |
repo string RequisThe name of the repository without the |
HTTP response status codes for "Export a software bill of materials (SBOM) for a repository."
| Status code | Description |
|---|---|
200 | OK |
403 | Forbidden |
404 | Resource not found |
Code samples for "Export a software bill of materials (SBOM) for a repository."
Request example
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/dependency-graph/sbomResponse
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": [
{
"SPDXID": "SPDXRef-Package",
"name": "rubygems:rails",
"versionInfo": "1.0.0",
"downloadLocation": "NOASSERTION",
"filesAnalyzed": false,
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION"
}
],
"relationships": [
{
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Repository",
"relatedSpdxElement": "SPDXRef-Package"
},
{
"relationshipType": "DESCRIBES",
"spdxElementId": "SPDXRef-DOCUMENT",
"relatedSpdxElement": "SPDXRef-Repository"
}
]
}
}