Registry / database / mongodb-stitch-api-client

mongodb-stitch-api-client

JSON →
library1.52.0jsnpmunverified

A Node.js client for the MongoDB Stitch (now Atlas App Services) Admin API. Version 1.52.0 is the latest stable release. It provides a convenient wrapper for managing Stitch applications, services, triggers, functions, rules, logs, security, and webhooks via the Admin API. It differs from the official MongoDB Realm Admin SDK by offering a more concise, promise-based interface with built-in authentication using API keys. The package includes TypeScript type definitions and supports both CommonJS and ESM environments. GitHub activity suggests maintenance has slowed; consider using the official @realm-app-services/admin-sdk for new projects.

npm install mongodb-stitch-api-client
INSTALL
IMPORT
SIG · MONGODB-STITCH-API
M
mongodb-stitch-api-client
databasejavascriptv1.52.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (function)
import getClient from 'mongodb-stitch-api-client'
const getClient = require('mongodb-stitch-api-client').getClient
Default export is a function that returns an object with services. CommonJS require works with default export.
StitchClient (type)
import type { StitchClient } from 'mongodb-stitch-api-client'
Type import for TypeScript users. The type is exported but not used as a value.
services (destructured)
const { trigger, application } = getClient(options)
import { trigger, application } from 'mongodb-stitch-api-client'
Services are returned by the client function, not directly importable.

Initializes the client with API keys, fetches all applications, creates a new app, and lists triggers. Uses environment variables for credentials.

import getClient from 'mongodb-stitch-api-client'; const client = getClient({ publicKey: process.env.STITCH_PUBLIC_KEY ?? '', privateKey: process.env.STITCH_PRIVATE_KEY ?? '', baseUrl: 'https://stitch.mongodb.com/api/admin/v3.0', projectId: process.env.STITCH_PROJECT_ID ?? '', appId: process.env.STITCH_APP_ID ?? '', // Optional }); async function main() { try { const apps = await client.application.getAll(); console.log('Applications:', apps); const newApp = await client.application.create({ name: 'MyStitchApp', deployment_model: 'LOCAL', location: 'IE', }); console.log('Created app:', newApp); const triggers = await client.trigger.getAll(); console.log('Triggers:', triggers); } catch (error) { console.error('Error:', error); } } main();
Debug
Known issues
gotchaThe client requires both 'projectId' and 'appId' for most operations, but 'appId' is optional for creating applications. Missing 'appId' will cause errors on calls like trigger.getAll().
fix
Always provide 'projectId' and 'appId' in options unless you are only using application creation/deletion.
affects: >=0.0.0
deprecatedMongoDB Stitch is rebranded as Atlas App Services. The API and this client may become outdated.
fix
Consider migrating to the official @realm-app-services/admin-sdk package.
affects: >=1.0.0
gotchaThe 'baseUrl' default is https://stitch.mongodb.com/api/admin/v3.0, but Atlas App Services uses https://services.cloud.mongodb.com/api/admin/v3.0 for newer accounts.
fix
Use the correct base URL for your account type: check MongoDB Atlas documentation.
affects: >=1.0.0
breakingIn version 1.52.0, the package changed from default export to named export? Actually it remains default export. No breaking changes reported.
fix
No fix needed.
affects: >=1.52.0
Errors
Common errors & fixes
Error: Request failed with status code 401
Invalid or missing API keys (publicKey/privateKey).
fix
Ensure your API keys are correct and have the required permissions in Atlas.
TypeError: Cannot destructure property 'trigger' of 'getClient(...)' as it is undefined.
The client function returned undefined due to missing or invalid projectId/appId.
fix
Verify that 'projectId' and 'appId' are provided and correct.
Error: getaddrinfo ENOTFOUND stitch.mongodb.com
The base URL is incorrect or not reachable.
fix
Use the correct base URL: https://stitch.mongodb.com/api/admin/v3.0 or https://services.cloud.mongodb.com/api/admin/v3.0.
Upgrade
Version history
1.52.0latest on npm
Audit
Dependencies
axiosrequiredHTTP client used for all API requests
lodash.getoptionalUsed for nested property extraction
Agent activity
11 hits · last 30 days
node
10
Resources
mongodb-stitch-api-client — npm install mongodb-stitch-api-client · libregistry