Last active
February 25, 2024 05:26
-
-
Save johnlpage/2e8bd55ed195cccd4af7cea718f1c640 to your computer and use it in GitHub Desktop.
Examples for MongoDB Atlas Data API Video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENDPOINT | |
-------- | |
https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta | |
API KEY | |
-------- | |
0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/insertOne \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database" : "household", | |
"collection" : "pets", | |
"document" : { "name": "Harvest", | |
"breed": "Labrador", | |
"age": 5 } | |
}' | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/findOne \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database" : "household", | |
"collection" : "pets", | |
"filter" : {"name" : "Harvest" } | |
}' | |
Postman | |
--------- | |
https://tinyurl.com/atlasdapi | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/insertMany \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database": "household", | |
"collection": "pets", | |
"documents": [{ | |
"name": "Brea", | |
"breed": "Labrador", | |
"age": 9, | |
"colour": "black" | |
}, | |
{ | |
"name": "Bramble", | |
"breed": "Labrador", | |
"age": 1, | |
"colour": "black" | |
} | |
] | |
}' | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/find \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database": "household", | |
"collection": "pets", | |
"filter": { "breed": "Labrador", | |
"age": { "$gt" : 2} }, | |
"sort": { "age": 1 } } | |
' | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/updateOne \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database": "household", | |
"collection": "pets", | |
"filter" : { "name" : "Harvest"}, | |
"update" : { "$set" : { "colour": "yellow" }} | |
}' | |
curl https://data.mongodb-api.com/app/data-amzuu/endpoint/data/beta/action/aggregate \ | |
-H 'Content-Type: application/json' \ | |
-H 'api-key: 0vaT8d5Vh9cgvm3KdIQJWkl5M8alZgnoOczmApFlWVTMqisg24QWrUfMS0wkQ5Sj' \ | |
--data-raw \ | |
'{ | |
"dataSource": "Cluster0", | |
"database": "household", | |
"collection": "pets", | |
"pipeline" : [ { "$match": {"breed": "Labrador"}}, | |
{ "$group": { "_id" : "$colour", | |
"count" : { "$sum" : 1}, | |
"average_age": {"$avg": "$age" }}}]}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment