18

Is there a workaround to get the list of organizations on GitHub?

For example: https://github.com/showcases/open-source-organizations

How can we do that via the GitHub API or GitHub search?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nam Vu
  • 5,669
  • 7
  • 58
  • 90

6 Answers6

14

You can get a list of all accounts:

https://developer.github.com/v3/users/#get-all-users

The type parameter will tell you if it's a user or organization.

An alternative is to use the search API:

https://developer.github.com/v3/search/#search-users

You can specify type:org to get organizations only:

https://api.github.com/search/users?q=type:org

Ivan Zuzak
  • 18,068
  • 3
  • 69
  • 61
  • how can i get objective C project of all organizations? – Nam Vu Jul 22 '14 at 00:03
  • @ZuzooVn I'm not sure I understand what you mean. Could you clarify your question please? – Ivan Zuzak Jul 22 '14 at 06:02
  • I want to get the list of organizations which have project with Objective C language. – Nam Vu Jul 22 '14 at 07:30
  • That's not possible currently. A workaround you could use is to get a list of all projects marked as Objective-C (using the Search API), and then get the owner of each project. If the owner is an organization (and not a personal account), you'd keep it in the list of organizations. – Ivan Zuzak Jul 22 '14 at 10:30
8

On June 17, 2015 GitHub added a new API to get organizations:

curl https://api.github.com/organizations

[
  {
    "login": "github",
    "id": 9919,
    "url": "https://api.github.com/orgs/github",
   "repos_url": "https://api.github.com/orgs/github/repos",
   "events_url": "https://api.github.com/orgs/github/events",
   "members_url": "https://api.github.com/orgs/github/members{/member}",
   "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
   "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=3",
    "description": "GitHub, the company."
  },
  ...
]

Additional information can be found on the following link:

List all organizations

Lists all organizations, in the order that they were created on GitHub.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of organizations.

Parameters

  • Name: since
  • Type: string
  • Description: The integer ID of the last Organization that you've seen.

Response

Status: 200 OK
Link: <https://api.github.com/organizations?since=135>; rel="next"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
----------------------------------------------------------------------
[
  {
    "login": "github",
    "id": 1,
    "url": "https://api.github.com/orgs/github",
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "description": "A great organization"
  }
]
Gabor Meszaros
  • 1,335
  • 1
  • 15
  • 25
3

Note that it's also possible to use Github GraphQL v4 to request organization using :

{
  search(query: "type:org", type: USER, first: 100) {
    userCount
    nodes {
      ... on Organization {
        name
        createdAt
        description
      }
    }
  }
}

Try it in the explorer

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
1

With the GitHub CLI gh 2.28.0 (Apr. 2023), you can also use the new gh org list command:

# List the first 30 organizations
$ gh org list

# List more organizations
$ gh org list --limit 100
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is helpful, but as of the time of this comment, this only lists organizations that you're a member of. – BillRobertson42 Jul 13 '23 at 13:46
  • @BillRobertson42 True, reading [`pkg/cmd/org/list/http.go`](https://github.com/cli/cli/pull/7257/files#diff-5d859b0dd3ceeca1f0703ad275b72c714664615a588de842ab137337ef03ee70R73-R75), this is based on User. – VonC Jul 13 '23 at 14:03
0

I ran into similar problems with you and maybe I get an answer from github API doc now.

Detail Doc in this: https://developer.github.com/v3/search/#search-users

There are several parameters that can be used.

  1. q : (string). The search terms.
  2. sort : (string). The sort field. Can be followers, repositories, or joined. Default: results are sorted by best match.
  3. order : (string). The sort order if sort parameter is provided. One of asc or desc. Default: desc

The q search term can also contain any combination of the supported user search qualifiers as described by the in-browser user search documentation and search syntax documentation:

  • type With this qualifier you can restrict the search to just personal accounts (user) or just organization accounts (org).
  • in Qualifies which fields are searched. With this qualifier you can restrict the search to just the username (login), public email (email), full name (fullname), or any combination of these.
  • repos Filters users based on the number of repositories they have.
  • location Filter users by the location indicated in their profile.
  • language Search for users that have repositories that match a certain language.
  • created Filter users based on when they joined.
  • followers Filter users based on the number of followers they have.

For your problem, you can try this example and change it.

For example:

https://api.github.com/search/users?q=language:objective-c+type:org&page=1

Request GET and return format data (json). Page parameter can be changed to get more pages of results (but no more than 1000, according current API doc).

P. Shi
  • 1
  • 2