Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 15, 2026·3 min de lecture

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.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 29/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Stage only
Confiance
Confiance : Established
Point d'entrée
Octokit.js Overview
Commande de staging sûr
npx -y tokrepo@latest install 732ce846-808e-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires