Jirong Hu
Jirong Hu

Reputation: 2375

What's my GitHub appliance's REST API endpoint?

I want to use Groovy, HttpBuilder and REST API to access our company's onsidte GitHub appliance. The GitHub developer's site: https://developer.github.com/v3/, shows this URL: https://api.github.com. So if my company's GitHub URL is: http://github.mycompany.com, what is my REST API endpoint URL? e.g. if I want to list all users, what's the correct URL?

When I access this URL: https://github.mycompany.com/api/v3, it gives me an error:

github.mycompany.com refused to connect. ERR_CONNECTION_REFUSED

Upvotes: 21

Views: 32772

Answers (5)

thowfeeq
thowfeeq

Reputation: 363

if you need https://github.com/google/shaka-player it would be https://api.github.com/repos/google/shaka-player

more info at https://api.github.com/

  "current_user_url": "https://api.github.com/user",

  "current_user_authorizations_html_url": https://github.com/settings/connections/applications{/client_id}",

  "authorizations_url": "https://api.github.com/authorizations",

  "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",

  "commit_search_url": "https://api.github.com/search/commits?q={query}{&page,per_page,sort,order}",

  "emails_url": "https://api.github.com/user/emails",

  "emojis_url": "https://api.github.com/emojis",

  "events_url": "https://api.github.com/events",

  "feeds_url": "https://api.github.com/feeds",

  "followers_url": "https://api.github.com/user/followers",

  "following_url": "https://api.github.com/user/following{/target}",

  "gists_url": "https://api.github.com/gists{/gist_id}",

  "hub_url": "https://api.github.com/hub",

  "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",

  "issues_url": "https://api.github.com/issues",

  "keys_url": "https://api.github.com/user/keys",

  "label_search_url": "https://api.github.com/search/labels?q={query}&repository_id={repository_id}{&page,per_page}",

  "notifications_url": "https://api.github.com/notifications",

  "organization_url": "https://api.github.com/orgs/{org}",

  "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",

  "organization_teams_url": "https://api.github.com/orgs/{org}/teams",

  "public_gists_url": "https://api.github.com/gists/public",

  "rate_limit_url": "https://api.github.com/rate_limit",

  "repository_url": "https://api.github.com/repos/{owner}/{repo}",

  "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",

  "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",

  "starred_url": "https://api.github.com/user/starred{/owner}{/repo}",

  "starred_gists_url": "https://api.github.com/gists/starred",

  "topic_search_url": "https://api.github.com/search/topics?q={query}{&page,per_page}",

  "user_url": "https://api.github.com/users/{user}",

  "user_organizations_url": "https://api.github.com/user/orgs",

  "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",

  "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"

Upvotes: 0

VonC
VonC

Reputation: 1323793

According to "API Enterprise 2.5":

All API endpoints—except Management Console API endpoints—are prefixed with the following URL:

https://hostname/api/v3/

But you need to authenticate:

Authentication

Your Enterprise installation's API endpoints accept the same authentication methods as the GitHub.com API. Specifically, you can authenticate yourself with OAuth tokens (which can be created using the Authorizations API) or basic authentication.

Every Enterprise API endpoint is only accessible to GitHub Enterprise site administrators, with the exception of the Management Console API, which is only accessible via the Management Console password.

Upvotes: 28

7ynk3r
7ynk3r

Reputation: 1008

TLTR; These are the endpoints

+----+------------------------------------------+--------------------------------+
|    |                Enterprise                |             GitHub             |
+----+------------------------------------------+--------------------------------+
| v3 | https://[YOUR_HOST]/api/v3               | https://api.github.com         |
| v4 | https://[YOUR_HOST]/api/graphql          | https://api.github.com/graphql |
+----+------------------------------------------+--------------------------------+

Examples

Here you have some examples in case you want to try them. You'll need to create an ACCESS_TOKEN

Enterprise

curl -H "Authorization: bearer [ACCESS_TOKEN]" https://[YOUR_HOST]/api/v3/organizations
curl -H "authorization: bearer [ACCESS_TOKEN]" https://[YOUR_HOST]/api/graphql -d "{\"query\": \"query { viewer { login } }\"}" 

GitHub

curl -H "Authorization: bearer [ACCESS_TOKEN]" https://api.github.com/organizations
curl -H "authorization: bearer [ACCESS_TOKEN]" https://api.github.com/graphql -d "{\"query\": \"query { viewer { login } }\"}" 

Upvotes: 15

Blaise Pabon
Blaise Pabon

Reputation: 63

You're getting that message because the request is not authenticated.

First you have to figure out what kind of auth your server accepts and then incorporate that into the header or the (query string) of your request.

For example, this is how I get a list (using the header approach) of organizations I can access:

`url -k -H "Authorization: token xxxxxx...xxx" \ https://git.acme.com/api/v3/organizations`

Note that xxxxx...xxx is a place holder for a personal access token I created with read-only access to my repos. The docs refer to this as OAUTH_TOKEN. You can opt for inserting the token as a query string. In neither case do you have to enter a user name because the server figures that out from the token.

Upvotes: 2

Jirong Hu
Jirong Hu

Reputation: 2375

If you are not using https, it's "http://github.mycompany.com/api/v3/".

Upvotes: 3

Related Questions