# Octokit.js — The Official GitHub SDK for JavaScript > A batteries-included JavaScript SDK for the GitHub REST and GraphQL APIs, usable in browsers, Node.js, and Deno with full TypeScript support. ## Install Save as a script file and run: # Octokit.js — The Official GitHub SDK for JavaScript ## Quick Use ```bash npm install octokit # In your script: # import { Octokit } from "octokit"; # const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); # const { data } = await octokit.rest.repos.get({ owner: "octokit", repo: "octokit.js" }); ``` ## Introduction Octokit.js is the official GitHub SDK for JavaScript and TypeScript. Maintained by GitHub, it provides a unified interface to the GitHub REST API, GraphQL API, and webhooks. It combines several lower-level packages (@octokit/rest, @octokit/graphql, @octokit/webhooks) into one cohesive library with automatic pagination, authentication, and rate limit handling. ## What Octokit.js Does - Provides typed methods for every GitHub REST API endpoint (repos, issues, PRs, actions, etc.) - Offers a GraphQL client for flexible, efficient queries against GitHub's GraphQL API - Handles multiple authentication strategies: personal access tokens, GitHub Apps, OAuth, and installation tokens - Includes automatic pagination helpers that iterate through all pages of results - Supports webhook event parsing and signature verification for GitHub App development ## Architecture Overview Octokit.js is a meta-package that combines @octokit/core (the HTTP client foundation), @octokit/rest (REST endpoint methods), @octokit/graphql (GraphQL queries), and @octokit/webhooks (event handling). The core layer handles authentication plugin injection, request/response hooks, and retry logic. REST endpoint methods are auto-generated from GitHub's OpenAPI specification, ensuring complete and up-to-date API coverage. The library runs in Node.js, browsers, and Deno without modification. ## Self-Hosting & Configuration - Install via npm: `npm install octokit` - Create a personal access token or GitHub App for authentication - Pass the token via the `auth` constructor option - For GitHub Apps, use `createAppAuth` from @octokit/auth-app - Configure custom base URLs for GitHub Enterprise Server instances ## Key Features - Auto-generated REST methods from GitHub's OpenAPI spec ensure complete API coverage - Built-in pagination with `octokit.paginate()` for iterating large result sets - Plugin architecture for extending functionality (retry, throttle, custom endpoints) - Full TypeScript types for all API methods, parameters, and responses - Webhook event verification for secure GitHub App development ## Comparison with Similar Tools - **PyGithub** — Python equivalent for GitHub API access; Octokit.js is the JavaScript counterpart - **@actions/github** — A thin Octokit wrapper pre-configured for GitHub Actions; Octokit.js is the full standalone SDK - **gh CLI** — Command-line GitHub tool; Octokit.js is for programmatic access in applications - **graphql-request** — Generic GraphQL client; Octokit.js adds GitHub-specific auth, pagination, and REST support ## FAQ **Q: Can I use Octokit.js in the browser?** A: Yes. It works in browsers, Node.js, and Deno with the same API. **Q: How do I authenticate as a GitHub App?** A: Use the @octokit/auth-app strategy, which handles JWT generation and installation token exchange. **Q: Does it support GitHub Enterprise?** A: Yes. Pass a custom `baseUrl` pointing to your GitHub Enterprise Server API endpoint. **Q: What license is Octokit.js under?** A: MIT License. ## Sources - https://github.com/octokit/octokit.js - https://github.com/octokit --- Source: https://tokrepo.com/en/workflows/asset-732ce846 Author: Script Depot