Search code examples
githubgithub-api

How to find my organization Id over github?


How I can find my GitHub organization id?

Ideally through a script or a command I can parse its output.


Solution

  • Type:

    curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/organizations
    

    (replace OAUTH-TOKEN by your own GitHub access token: see "Git automation with OAuth tokens" to get or create a PAT: a Personal Access Token)

    You will see that you can below to more than one organization.

    For each one:

    curl -H "Accept: application/json" -H "Authorization: token OAUTH-TOKEN" https://api.github.com/organizations/<anorg> | jq ".id"
    

    With jq (lightweight command-line JSON processor, which is available for all OS including Windows), you will get directly the id.