$ npm install octocat --save
const GitHub = ;// Using an access tokenconst client =token: 'my-access-token';// Using an username/passwordconst client =username: 'SamyPesse'password: 'my-password';// Connecting to an enterprise versionconst client =endpoint: '';
All of these methods return promises.
These methods return a
response object that looks like:
// HTTP Status codestatusCode: 200// Type of status: 2XX, 3XX, 4xxstatusType: '2XX'// Headers returned by the serverheaders: ...// Body of the requestbody: ...
In case of error, the response can also be accessible using as a
Some methods of Octonode return paginated results. Check on GitHub which API methods are paginated.
These methods return a
page.listcontains the list of results in the current page
page.next()update with the results of the next page (Promised)
page.prev()update with the results of the previous page (Promised)
page.all()return all the results by recursively calling the API
// Get a single userconst user = client;user;// Get the authenticated userconst user = client;// Edit the authenticated useruser
// Create a new repositoryclient;// Get public repositories (paginated)client;// List user repositoriesuser;// Get a single repositoryconst repo = client;repo;// Compare two commitsrepo;// Perform a mergerepo;// Delete the repositoryrepo
// List issues for a repositoryrepo;// Create an issue in a repositoryrepo;// Get a single issue in a repositoryconst issue = repo;issue;// Edit an issueissue
// List organizations of an useruser;// Check an user's membership to an organizationuser;// List an user's memberships to all of his organizationsuser;// Get a single organizationconst org = client;org;// Edit the organizationorg// List members of the organizationorg;// Create a new repositoryorg;
// List commits for a repositoryrepo;// Get a single commitconst commit = repo;commit;
// Create a Statusrepo;// List Statuses for a specific Refcommit;
// List branches for a repositoryrepo;// Get a single branchconst branch = repo;branch;
// List tags for a repositoryrepotags;
// List hooks for a repositoryrepo;// Get a single hookconst hook = repo;hook;// Edit a hookhook// Delete the hookhook
// List releases of a repositoryrepo;// Get details about the releaseconst release = repo;release;// Edit a releaserelease// Delete the releaserelease
// Upload a new asset as file/streamrelease;release;
release.upload will also notify with progress:
// List assets of a releaserelease;// Get details about the releaseconst asset = release;asset;// Download the asset to a fileasset;// Download the asset to a streamasset;// Delete the assetasset
// List email addressesclient;// Add email address(es)client;// Delete email address(es)client;
const app = client;const token = app;// Check an authorizationtoken;// Reset an authorizationtoken;// Delete an authorizationtoken;
const ref = repo;// Get a referenceref;// Edit / Deleteref;ref;
const commit = repo;// Get a commitcommit;
You can also check your rate limit status by calling the following.