Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

github-api

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

like image 475
Jirong Hu Avatar asked Apr 08 '16 15:04

Jirong Hu


2 Answers

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.

like image 139
VonC Avatar answered Oct 28 '22 02:10

VonC


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 } }\"}" 
like image 37
7ynk3r Avatar answered Oct 28 '22 02:10

7ynk3r