Database / Azure Cosmos DB interview questions
What are the different APIs available in Azure Cosmos DB?
Azure Cosmos DB is a multi-model database, meaning a single back-end engine exposes different wire-protocol-compatible APIs so you can interact with data using the client libraries and query syntax you already know. As of 2024, six APIs are available:
| API | Data Model | Best For |
|---|---|---|
| NoSQL (Core) | JSON documents | New applications, native Cosmos SDK, richest feature set |
| MongoDB | BSON documents | Migrating existing MongoDB apps; wire-compatible with MongoDB drivers |
| Cassandra | Column-family / CQL | Migrating Apache Cassandra workloads; CQL wire protocol |
| Gremlin | Property graph | Social graphs, recommendation engines, highly connected data |
| Table | Key-value (entities) | Migrating Azure Table Storage apps with minimal code changes |
| PostgreSQL (vCore) | Relational / SQL | Distributed relational workloads using the Citus extension on PostgreSQL |
The NoSQL API is the native API with the fullest feature parity — it supports the richest query language, all five consistency levels, server-side JavaScript (stored procedures, triggers), and change feed. The other APIs are compatibility layers that let you point existing drivers at Cosmos DB. The MongoDB API, for example, implements the MongoDB wire protocol, so a Node.js app using Mongoose can switch from Atlas to Cosmos DB by changing the connection string with no code changes.
An important nuance: each account is bound to one API at creation time. You cannot switch APIs after account creation, so choosing the right API upfront is critical. If you have no legacy migration requirement, the NoSQL API is always the recommended starting point.
More Related questions...