November 19th, 2024

Data API Public Preview in vCore-based Azure Cosmos DB for MongoDB

Sajeetharan Sinnathurai
Principal Program Manager

We’re excited to announce that the Data API for vCore-based Azure Cosmos DB for MongoDB is now in public preview. This Data API offers a flexible and powerful way for you to interact with your database using HTTP-based API calls.Data API 

The Data API for vCore-based Azure Cosmos DB for MongoDB lets you work with your MongoDB vCore data through straightforward HTTP requests, removing the need for traditional drivers or complex queries. You can easily perform basic operations like creating, reading, updating, and deleting data directly from your applications. This approach simplifies connecting your MongoDB data to web apps, mobile apps, or tools like Power BI, all through a familiar and user-friendly API. With this API, you can interact with MongoDB data directly from applications, including web, mobile, or serverless environments, without needing a MongoDB driver or managing a backend server.

Image data api

Here are some of the key reasons and benefits for using the MongoDB Data API: 

How it helps 

The Data API simplifies interactions with Azure Cosmos DB for MongoDB by providing a direct HTTP-based method to access data. It provides benefits such as, 

Ease of Integration with Frontend Apps 

The MongoDB vCore Data API enables direct interaction with MongoDB vCore data over HTTP, reducing backend requirements and simplifying frontend integration for web and mobile apps.  

Reduced Backend overhead 

The Data API enables direct access to MongoDB vCore, eliminating the need for a custom backend and reducing infrastructure and maintenance costs. By abstracting database connectivity, it lets developers focus on core app features rather than managing connections and error handling. This approach simplifies code and speeds up development for streamlined applications.

Support for Multiple Data Types and Aggregation 

The API supports MongoDB BSON data types, including dates and embedded documents, enabling structured data handling. It integrates with MongoDB’s aggregation framework, which facilitates advanced operations like filtering, grouping, and transforming data. This makes the API ideal for applications with complex data requirements.When to Use the MongoDB Data API vs. a Traditional Driver 

In general, the MongoDB vCore Data API is ideal when: 

  • You are working in an environment where a direct MongoDB driver is impractical (e.g., mobile, frontend). 
  • You want to avoid backend complexity, especially for simpler applications. 

Conversely, if you need higher performance, lower latency, or specialized database functions not available in the Data API, a traditional MongoDB driver may be better suited. 

Getting Started: 

Here is an example of how to use Data API: 

Example 

To read active products from a products collection: 

curl --location --request POST 'https://data.mongodbvcore-api.com/app/<APP ID>/endpoint/data/v1/action/find' \
--header 'Content-Type: application/json' \
--header 'Access-Control-Request-Headers: *' \
--header 'api-key: <YOUR API KEY>' \
--data-raw '{
    "dataSource": "Cluster0",
    "database": "myDatabase",
    "collection": "products",
    "filter": { "status": "active" }
}'

This retrieves all documents from the products collection where status is active, using a straightforward HTTP request. 

If you’re excited about what this feature can do for you, try it out today ! Check out  documentation  to get started. 

Conclusion 

The MongoDB vCore Data API provides a versatile, secure, and simple method for accessing MongoDB databases over HTTP, supporting a range of applications, from web and mobile . By simplifying the connection to MongoDB vCore, it speeds up development and reduces backend complexity. 

Leave a review 

Tell us about your Azure Cosmos DB experience! Leave a review on PeerSpot and we’ll gift) you $50. Get started here. 

 About Azure Cosmos DB 

Azure Cosmos DB is a fully managed and serverless distributed database for modern app development, with SLA-backed speed and availability, automatic and instant scalability, and support for open-source PostgreSQL, MongoDB, and Apache Cassandra. Try Azure Cosmos DB for free here. To stay in the loop on Azure Cosmos DB updates, follow us on X, YouTube, and LinkedIn.

Author

Sajeetharan Sinnathurai
Principal Program Manager

Principal Product Manager passionate about empowering developers with exceptional tools and experiences. Currently part of the Azure Cosmos DB team, driving developer-focused features like GraphQL, JavaScript SDK, integrations, and tooling. Interested in web development or cloud? Let’s connect!

0 comments