| CARVIEW |
Organizations API
API for accessing and modifying organizations.
Getting Organization Information
You can get the full information on organizations by the screen name:
/organizations/:org [GET]
$ curl https://github.com/api/v2/json/organizations/github
{
"organization": {
"name": "GitHub",
"company": null,
"gravatar_id": "61024896f291303615bcd4f7a0dcfb74",
"location": "San Francisco, CA",
"created_at": "2008-05-10T21:37:31-07:00",
"blog": "https://github.com/blog",
"public_gist_count": 0,
"public_repo_count": 20,
"following_count": 0,
"id": 9919,
"permission": null,
"type": "Organization",
"followers_count": 532,
"login": "github",
"email": "support@github.com"
}
}
Owners can update the organization with these fields:
nameemailblogcompanylocationbilling_email/organizations/:org [PUT]
You can send POST params:
$ curl -d "organization[name]=New%20Name" \
https://github.com/api/v2/json/organizations/github
You can also send JSON:
$ curl -H "Content-Type: application/json" \
-d '{"organization": {"name": "New Name"}}' \
https://github.com/api/v2/json/organizations/github
Checking Organization Membership
You can get all the public organizations that a user is part of:
/user/show/:user/organizations [GET]
$ curl https://github.com/api/v2/json/organizations/technoweenie
{
"organizations": [
{
"name": "GitHub",
"company": null,
"gravatar_id": "61024896f291303615bcd4f7a0dcfb74",
"location": "San Francisco, CA",
"created_at": "2008-05-10T21:37:31-07:00",
"blog": "https://github.com/blog",
"public_gist_count": 0,
"public_repo_count": 20,
"following_count": 0,
"id": 9919,
"permission": null,
"type": "Organization",
"followers_count": 532,
"login": "github",
"email": "support@github.com"
}
]
}
You can get a list of all of your organizations:
/organizations [GET]
Listing Organization Memberships
You can list all repositories across all the organizations that you can access:
/organizations/repositories [GET]
$ curl https://github.com/api/v2/json/organizations/repositories
{
"repositories": [
{
"name": "gollum",
"has_wiki": true,
"created_at": "2010/03/29 11:30:53 -0700",
"watchers": 607,
"private": false,
"fork": false,
"url": "https://github.com/github/gollum",
"pushed_at": "2010/12/02 19:28:28 -0800",
"open_issues": 34,
"has_downloads": true,
"permission": "admin",
"homepage": "",
"has_issues": true,
"organization": "github",
"forks": 54,
"description": "A simple, Git-powered wiki with a sweet API and local frontend.",
"owner": "github"
}
]
}
You can also list all public repositories of any other organization:
/organizations/:org/public_repositories [GET]
You can list all public members of any organization:
/organizations/:org/public_members [GET]
$ curl https://github.com/api/v2/json/organizations/github/public_members
{
"users": [
{
"name": "Corey Donohoe",
"company": "GitHub",
"gravatar_id": "a86224d72ce21cd9f5bee6784d4b06c7",
"location": "Potrero, SF",
"created_at": "2008-01-22T01:14:11-08:00",
"blog": "https://www.atmos.org",
"public_gist_count": 140,
"public_repo_count": 80,
"following_count": 149,
"id": 38,
"permission": null,
"type": "User",
"followers_count": 244,
"login": "atmos",
"email": "atmos@atmos.org"
}
]
}
Teams API
API for accessing and modifying teams. These actions all require you to have admin access for the Organization and/or the Team. If using OAuth, make sure you are armed with the 'repo' scope.
Listing Organization Teams
/organizations/:org/teams [GET]
$ curl https://github.com/api/v2/json/organizations/github/teams [GET]
{
"teams": [
{
"name": "Open Source",
"id": 10,
"permission": "admin"
}
]
}
Creating a Team
/organizations/:org/teams [POST]
The applicable fields for Teams are:
- name
- permission (admin/push/pull)
- repo_names (array)
You can send this data as POST params:
$ curl -d "team[name]=my-team" -d "team[permission]=admin" \
-d "team[repo_names][]=:user/:repo" -d "team[repo_names][]=:user/:repo" \
https://github.com/api/v2/json/organizations/github/teams
{
"team": {
"name": "test",
"id": 123,
"permission": "pull"
}
}
You can also send it as JSON:
$ curl -d '{"team":{"name":"my-team", "repo_names":[":user/:repo"]}}' \
-H "Content-Type: application/json" \
https://github.com/api/v2/json/organizations/github/teams
Fetching and Updating Team Information
/teams/:team_id [GET]
$ curl https://github.com/api/v2/json/teams/10 [GET]
{
"team": {
"name": "Open Source",
"id": 10,
"permission": "admin"
}
}
You can update a Team by sending the following attributes (with the correct Content-Type):
/teams/:team_id [PUT]
$ curl -X PUT -d '{"team": {"name": "OSS"}}' \
-H "Content-Type: application/json" \
https://github.com/api/v2/json/teams/10
{
"team": {
"name": "OSS",
"id": 10,
"permission": "admin"
}
}
You can also DELETE a Team:
/teams/:team_id [DELETE]
$ curl -X DELETE \
https://github.com/api/v2/json/teams/10
Team Members
To list users:
/teams/:team_id/members [GET]
$ curl https://github.com/api/v2/json/teams/10/members
{
"users": [
{
"gravatar_id": "b8dbb1987e8e5318584865f880036796",
"company": "GitHub",
"name": "Chris Wanstrath",
"location": "San Francisco, CA",
"blog": "https://chriswanstrath.com/",
"type": "User",
"login": "defunkt",
"email": "chris@wanstrath.com"
}
]
}
To add a user to the team:
/teams/:team_id/members?name=:user [POST]
$ curl -d "name=technoweenie" https://github.com/api/v2/json/teams/10/members
To remove a user from the team:
/teams/:team_id/members?name=:user [DELETE]
Team Repositories
To list repositories:
/teams/:team_id/repositories [GET]
$ curl https://github.com/api/v2/json/teams/10/repositories
{
"repositories": [
{
"name": "albino",
"created_at": "2008-05-10T21:45:03-07:00",
"has_wiki": false,
"watchers": 59,
"private": false,
"fork": false,
"url": "https://github.com/github/albino",
"pushed_at": "2010-10-11T11:09:50-07:00",
"has_downloads": false,
"open_issues": 2,
"homepage": "",
"has_issues": true,
"organization": "github",
"forks": 6,
"description": "Ruby wrapper for the Pygments syntax highlighter.",
"owner": "github"
}
]
}
To add a repo to the team:
/teams/:team_id/repositories?name=:user/:repo [POST]
$ curl -d "name=github/gollum" https://github.com/api/v2/json/teams/10/repositories
To remove a repo from the team:
/teams/:team_id/repositories?name=:user/:repo [DELETE]
