Loading lessons...
The Data API
The Data API
The MongoDB Data API lets you query and update Atlas data over plain HTTPS endpoints - no language driver required. It's handy when a driver isn't available or is overkill.
When to use it
- Drivers aren't available for your platform.
- You want a simple HTTP request instead of a driver.
- Serverless functions and quick integrations.
Enabling the Data API
In the Atlas UI:
- Open Data API and enable it for your cluster.
- Choose an access level (No Access, Read Only, Read and Write, or Custom).
- Create a Data API key - it's shown only once, so save it.
- Note the App ID from the endpoint URL.
Example: findOne via HTTPS
curl --location --request POST 'https://data.mongodb-api.com/app/<DATA API APP ID>/endpoint/data/v1/action/findOne' \
--header 'Content-Type: application/json' \
--header 'api-key: <DATA API KEY>' \
--data-raw '{
"dataSource": "<CLUSTER NAME>",
"database": "sample_mflix",
"collection": "movies",
"projection": { "title": 1 }
}'
The endpoints
The Data API exposes these actions:
| Action | Purpose |
|---|---|
| findOne / find | Read documents |
| insertOne / insertMany | Create documents |
| updateOne / updateMany | Update documents |
| deleteOne / deleteMany | Delete documents |
| aggregate | Run an aggregation pipeline |
Every request body includes dataSource (your cluster name), database, and collection.
TL;DR
- The Data API exposes CRUD + aggregation over HTTPS.
- Requires enabling it and a Data API key.
- A good fallback when drivers aren't available.