Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List dependents of a Github repository via Github API

The Github webpage shows on every repo's insights page what repos are dependent on it: https://github.com/django/django/network/dependents

Via the Github API you seem to only get the repos that your repo depends on not the repos that are dependent on your repo. See Repository.dependencyGraphManifests: https://docs.github.com/en/graphql/reference/objects#repository

Did I miss something or is it just not possible to get the dependents via the API?

like image 570
Jonathan Avatar asked Mar 17 '26 20:03

Jonathan


1 Answers

Sure, you can install github-dependents-info and use it in your Python script like other APIs.

For example, the following script:

from github_dependents_info.gh_dependents_info import GithubDependentsInfo
import json

gh_deps_info = GithubDependentsInfo(
            'aimhubio/aim',
            debug=False,
            sort_key='name',
            min_stars=0,
            json_output=True,
            badge_markdown_file=False,
            badge_color='informational',
            merge_packages=True,
        )

dependents = gh_deps_info.collect()
with open('aim_dependents.json', 'w') as f:
    json.dump(dependents, f, indent=4)

is equivalent to the CLI command:

github-dependents-info --repo aimhubio/aim -p -j > "aim_dependents.json"

Try it out and give me a like!

like image 67
Jimmy Zhao Avatar answered Mar 22 '26 06:03

Jimmy Zhao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!