msgraph-sdk-javascript

Official Microsoft Graph JavaScript SDK for calling the Graph API from Node.js and the browser.

SDK
npm
v3.0.7
833stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
58/100Fair
Development Activity24
Maintenance36
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture84
Code Quality82
Innovation62
Learning Curve100

The Microsoft Graph JavaScript client library is Microsoft’s official wrapper around the Microsoft Graph REST API, giving Node.js and browser applications a fluent client.api(path).get()-style interface instead of hand-rolled fetch calls. It handles authentication provider wiring, request/response middleware, retries, redirects, and telemetry so callers can focus on which Graph resource (users, mail, files, Teams, etc.) they need rather than the plumbing to reach it.

Beyond the basic request builder, the SDK ships purpose-built tasks for two hard problems in the Graph API surface: chunked large-file uploads to OneDrive/SharePoint/Outlook/Print via LargeFileUploadTask, and paged collection traversal via PageIterator. A pluggable middleware chain (authentication, retry, redirect, telemetry, and a chaos-testing handler for simulating failures) lets consumers customize behavior without forking the client, and first-class authentication provider adapters exist for MSAL browser, Azure Identity token credentials, and custom providers.

What You Get

  • A fluent Client.init(...).api(path).get()/.post()/.patch() request builder covering all Graph HTTP verbs, OData query parameters, and custom headers/options
  • A default middleware chain (AuthenticationHandler, RetryHandler, RedirectHandler, TelemetryHandler, HTTPMessageHandler) that can be replaced or extended with custom middleware
  • LargeFileUploadTask/OneDriveLargeFileUploadTask for chunked, resumable uploads to OneDrive, SharePoint, Outlook, and the Print API
  • PageIterator for transparently walking paginated Graph collections (e.g. /me/messages) without manual @odata.nextLink handling
  • Built-in authentication provider adapters for MSAL Browser, Azure Identity TokenCredential, and any custom auth callback
  • A ChaosHandler middleware for simulating Graph API failures (throttling, 5xx errors) in tests

Common Use Cases

  • Building an SPA (Angular/React/Vanilla JS) that signs users in with MSAL and calls Microsoft Graph to read profile, mail, or calendar data
  • A Node.js/Express backend service that authenticates with client credentials via Azure Identity and manages Microsoft 365 resources on behalf of an app
  • Uploading large files (videos, backups) to OneDrive or SharePoint in resumable chunks instead of a single oversized request
  • Iterating a user’s full mailbox or a large SharePoint list page-by-page without writing manual @odata.nextLink loops
  • Sending mail, managing calendar events, or querying directory/user data as part of an internal M365 automation tool

Under The Hood

Architecture The SDK is layered around a small core: Client (in src/Client.ts) is a thin factory that resolves an HTTPClient from either an authProvider (wrapped via CustomAuthenticationProvider) or a fully custom middleware array, then hands out GraphRequest instances from client.api(path). GraphRequest (src/GraphRequest.ts) owns URL assembly (host, Graph API version, OData query params) and delegates the actual call to the shared HTTPClient, which runs the request through a linked chain of Middleware implementations (AuthenticationHandler, RetryHandler, an optional RedirectHandler in Node, TelemetryHandler, and a terminal HTTPMessageHandler) assembled by MiddlewareFactory.getDefaultMiddlewareChain. This chain-of-responsibility design is the extension point: swapping Client.init for Client.initWithMiddleware lets callers substitute their own chain (including the ChaosHandler for fault injection) without touching GraphRequest or Client at all. Two independent task classes, LargeFileUploadTask and PageIterator, sit outside the core request path and consume the same Client/GraphRequest surface to implement chunked uploads and pagination as composable helpers rather than special-cased branches inside the client itself.

Tech Stack The library is written in TypeScript and built with tsc into parallel CJS and ES module outputs (tsconfig-cjs.json/tsconfig-es.json), then bundled with Rollup (rollup.config.js) for the browser script-tag distribution; Babel (@babel/preset-env, @babel/plugin-transform-runtime) handles down-leveling for older runtimes. Runtime dependencies are deliberately minimal — just @babel/runtime and tslib — with the Fetch API as the sole HTTP primitive (callers must supply a fetch polyfill like isomorphic-fetch on older Node). Authentication integrates with @azure/msal-browser and @azure/identity as peer/dev dependencies for MSAL and token-credential flows respectively, and @microsoft/microsoft-graph-types supplies Graph’s TypeScript model typings separately from this package.

Code Quality Testing runs on Mocha with Chai assertions for Node-targeted test:cjs, plus Karma with ChromeHeadless for browser-targeted specs, and coverage is tracked via nyc; the test/ tree mirrors src/ with dedicated suites for authentication, middleware, tasks, and core request-building, including dummy/fake providers (DummyAuthenticationProvider, DummyHTTPMessageHandler) for isolating middleware behavior. ESLint (.eslintrc.json) and Prettier (.prettierrc) are enforced via Husky pre-commit hooks and lint-staged, and GitHub Actions CI (ci_validation.yml) builds and tests against Node 16/18/20 on every pull request, alongside a separate CodeQL security-analysis workflow. Errors are represented as typed GraphError/GraphClientError classes surfaced through a dedicated GraphErrorHandler rather than left as raw thrown values, and public classes/interfaces carry consistent JSDoc @module/@public/@private annotations throughout.

What Makes It Unique Rather than being a generic HTTP client pointed at Graph, the SDK bakes in solutions to Graph-specific pain points: LargeFileUploadTask/OneDriveLargeFileUploadTask implement Graph’s resumable byte-range upload session protocol for OneDrive, SharePoint, Outlook, and Print, and PageIterator automates @odata.nextLink traversal so callers never hand-roll pagination loops. The middleware chain’s ChaosHandler is a distinctive addition for a client SDK — it lets consumers simulate Graph throttling and server errors in their own test suites to validate retry/backoff behavior without depending on the live service misbehaving. Multiple interchangeable authentication provider adapters (MSAL Browser, Azure Identity token credentials, custom callback) reflect Microsoft’s own evolving identity story being absorbed into one client rather than pushed onto every consumer.

Used by 8 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

24,298

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript99%
Updated today
TypeScript
100%
MIT

Botpress

AI Assistants · AI Development · Customer Support

14,893

The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript100%
Updated 3 days ago
TypeScript
74%
Apache 2.0

Jitsi Meet

Team Chat · Collaboration · Video Conferencing

29,879

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
96
Repo Health
85
Technical
69
Dependency
Built with
TypeScript74%
JavaScript10%
Updated yesterday
TypeScript
81%
MIT

LibreChat

Developer Tools · AI Assistants

42,871

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript81%
JavaScript18%
Updated today
TypeScript
96%
AGPL 3.0

Midday

Invoicing Finance · Productivity

14,958

All-in-one AI-powered business operations platform for freelancers and solo entrepreneurs to manage invoicing, time tracking, banking, and financial intelligence.

View details
55
Repo Health
78
Technical
70
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
80%
Apache 2.0

nao

AI Development · Analytics

1,611

Build and deploy an open-source analytics agent that understands your data warehouse and answers business questions in plain English.

View details
84
Repo Health
76
Technical
67
Dependency
Built with
TypeScript80%
Python19%
Updated yesterday
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,861

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
90
Repo Health
77
Technical
62
Dependency
Built with
TypeScript64%
Vue31%
Updated 2 days ago
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search