2016-09-24 79 views

回答

2

the Organization API,請訪問

https://api.github.com/orgs?access_token=OAUTH-TOKEN 

或者類型:

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

(由你自己的GitHub的訪問令牌替換OAUTH-TOKEN:詳見 「Git automation with OAuth tokens」 來獲得或創建PAT:個人訪問令牌)

你會告訴你,你可以低於多個組織。

對於每一個:

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

隨着jq (lightweight command-line JSON processor,這是可以for all OS包括Windows),您將得到直接的ID。

2

你可以用下面的命令找到它:

curl -H "Authorization: token personal-access-token" https://api.github.com/orgs/name-of-your-org 

此命令的輸出是這樣的:

{ 
    "login": "your-org", 
    "id": 15156947, 
    "url": "https://api.github.com/orgs/your-org", 
    "repos_url": "https://api.github.com/orgs/your-org/repos", 
    "events_url": "https://api.github.com/orgs/your-org/events", 
    "hooks_url": "https://api.github.com/orgs/your-org/hooks", 
    "issues_url": "https://api.github.com/orgs/your-org/issues", 
    "members_url": "https://api.github.com/orgs/your-org/members{/member}", 
    "public_members_url": "https://api.github.com/orgs/your-org/public_members{/member}", 
    "avatar_url": "https://avatars.githubusercontent.com/u/15056937?v=3", 
    "description": "", 
    "name": "", 
    "company": null, 
    "blog": "", 
    "location": "", 
    "email": "", 
    "public_repos": 1, 
    "public_gists": 0, 
    "followers": 0, 
    "following": 0, 
    "html_url": "https://github.com/your-org", 
    "created_at": "2013-11-09T21:58:06Z", 
    "updated_at": "2014-09-18T16:54:44Z", 
    "type": "Organization", 
    "total_private_repos": 0, 
    "owned_private_repos": 0, 
    "private_gists": 0, 
    "disk_usage": 0, 
    "collaborators": 0, 
    "billing_email": "[email protected]", 
    "plan": { 
    "name": "free", 
    "space": 976562499, 
    "private_repos": 0, 
    "filled_seats": 2, 
    "seats": 0 
    } 
} 

所以第二行包含所需的組織ID:

"id": 15156947 

希望能幫助別人。