{"id":43140,"library":"mongodb-data-api","title":"MongoDB Data API SDK","description":"A Node.js SDK for MongoDB Atlas Data API, providing a typed, promise-based client to interact with MongoDB via HTTP endpoints. Current stable version is 0.4.0, released as an early-stage package with monthly commits. Key differentiators: full TypeScript support, method chaining for cluster/database/collection selection, and native support for all Data API actions (CRUD, aggregation). Alternatives like the official MongoDB driver require direct database connection, while this SDK works over HTTP-only Data API, suitable for serverless or restricted network environments.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/surmon-china/mongodb-data-api","tags":["javascript","MongoDB data API","MongoDB cloud data API","MongoDB Atlas data API SDK","typescript"],"install":[{"cmd":"npm install mongodb-data-api","lang":"bash","label":"npm"},{"cmd":"yarn add mongodb-data-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add mongodb-data-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will fail unless using dynamic import.","wrong":"const createMongoDBDataAPI = require('mongodb-data-api').createMongoDBDataAPI","symbol":"createMongoDBDataAPI","correct":"import { createMongoDBDataAPI } from 'mongodb-data-api'"},{"note":"The type is exported as a TypeScript type, not a value. Use `import type` for type-only usage.","wrong":"import { MongoDBDataAPI } from 'mongodb-data-api'","symbol":"MongoDBDataAPI","correct":"import type { MongoDBDataAPI } from 'mongodb-data-api'"},{"note":"Interface for options passed to createMongoDBDataAPI.","wrong":"","symbol":"MongoDBDataAPIOptions","correct":"import type { MongoDBDataAPIOptions } from 'mongodb-data-api'"}],"quickstart":{"code":"import { createMongoDBDataAPI } from 'mongodb-data-api';\n\nconst api = createMongoDBDataAPI({\n  apiKey: process.env.MONGODB_API_KEY ?? '',\n  appId: process.env.MONGODB_APP_ID ?? '',\n});\n\nasync function run() {\n  const result = await api.findOne({\n    dataSource: 'Cluster0',\n    database: 'sample_airbnb',\n    collection: 'listingsAndReviews',\n    filter: { property_type: 'Apartment' },\n  });\n  console.log(result.document);\n}\n\nrun();","lang":"typescript","description":"Initialize the client using environment variables and perform a findOne operation."},"warnings":[{"fix":"Pin to a specific version and test upgrades carefully.","message":"Version 0.x is pre-release; API may change without major version bump.","severity":"breaking","affected_versions":">=0.0.0 <1.0.0"},{"fix":"Use 'urlEndpoint' instead of 'appId' when possible for clarity.","message":"The 'region' and 'cloud' options on init are no longer needed if using urlEndpoint directly.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Wrap calls in try/catch and check error message for HTTP status.","message":"All action methods return raw HTTP response data; errors are thrown as generic Error with status code.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use chaining after creating API instance; see chaining example in README.","message":"The $cluster, $database, $collection chaining methods are not documented in README but exist in source.","severity":"gotcha","affected_versions":">=0.4.0"},{"fix":"Check the actual API response and add explicit type assertions if needed.","message":"TypeScript types for action parameters may be incomplete; some options may accept 'any'.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.4.0':31 'action':59 'aggreg':61 'altern':62 'api':3,12,58,81,92,96,100 'atlas':10,98 'base':18 'chain':48 'client':19 'cloud':94 'cluster/database/collection':50 'commit':41 'connect':71 'crud':60 'current':27 'data':2,11,57,80,91,95,99 'databas':70 'differenti':43 'direct':69 'driver':67 'earli':36 'early-stag':35 'endpoint':26 'environ':88 'full':44 'http':25,78 'http-on':77 'interact':21 'javascript':89 'key':42 'like':63 'method':47 'mongodb':1,9,23,66,90,93,97 'month':40 'nativ':53 'network':87 'node.js':6 'offici':65 'packag':38 'promis':17 'promise-bas':16 'provid':13 'releas':32 'requir':68 'restrict':86 'sdk':4,7,74,101 'select':51 'serverless':84 'stabl':28 'stage':37 'suitabl':82 'support':46,54 'type':15 'typescript':45,102 'version':29 'via':24 'work':75","created_at":"2026-06-05T16:58:22.712785+00:00","updated_at":"2026-06-05T16:58:22.712785+00:00","problems":[{"fix":"Configure tsconfig.json properly or use .mjs extension for Node.js ESM.","cause":"Package is ESM-only; TypeScript projects need \"module\": \"ESNext\" and \"moduleResolution\": \"bundler\" in tsconfig.json.","error":"Cannot find module 'mongodb-data-api' or its corresponding type declarations."},{"fix":"Use dynamic import: const { createMongoDBDataAPI } = await import('mongodb-data-api'); or switch to ESM.","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: createMongoDBDataAPI is not a function"},{"fix":"Use the returned property directly (e.g., result.document) rather than result.data.","cause":"Action methods return shaped objects (e.g., { document }) instead of raw response; TypeScript types may not match actual shape.","error":"Property 'data' does not exist on type '{ document: any } & ...'"},{"fix":"Provide either urlEndpoint or appId, not both; in newer versions both are allowed but urlEndpoint takes precedence.","cause":"Passing both 'urlEndpoint' and 'appId' to createMongoDBDataAPI caused conflict in early versions.","error":"Expected 0-1 arguments, but got 2."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/surmon-china/mongodb-data-api#readme","github":"https://github.com/surmon-china/mongodb-data-api","docs":null,"changelog":null,"pypi":null,"npm":"mongodb-data-api","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}