github-api icon indicating copy to clipboard operation
github-api copied to clipboard

How to extract the dependencies of a repository?

Open tohidemyname opened this issue 3 months ago • 2 comments

I notice that Github has a rest api to retrieve the dependencies of a repository:

https://docs.github.com/en/rest/dependency-graph/sboms?apiVersion=2022-11-28#export-a-software-bill-of-materials-sbom-for-a-repository

However, I did not find a corresponding API call in github-api. I tried to implement the api by myself:

public List<Dependence> getDependGraph() throws IOException {
		Dependence[] list = root().createRequest()
	                .withUrlPath(getApiTailUrl("dependency-graph/sbom"))
	                .fetch(Dependence[].class);
	    return Arrays.asList(list);
		
	}

The above code returns a 404 error:

org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/sgtest/pinned-lucene/stats/dependency-graph/sbom {
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest",
  "status": "404"
}

I tried to call the url: https://api.github.com/repos/sgtest/pinned-lucene/stats/dependency-graph/sbom

It also returns a 404 error.

Is this a problem in Github? Would you please give me some suggestions on how to implement the API for github-api?

tohidemyname avatar Sep 25 '25 02:09 tohidemyname

I find the correct url: https://api.github.com/repos/sgtest/pinned-lucene/dependency-graph/sbom

tohidemyname avatar Sep 25 '25 02:09 tohidemyname

Great! Please add a test and submit a PR!

bitwiseman avatar Oct 23 '25 18:10 bitwiseman