Cosmos DB API Selection Guide

Cosmos DB API Selection Guide

Watch the video to deepen your understanding.

Subscribe

Complete the full lesson to earn 25 points

Work through each section, then tap “Mark as Complete” on the last one.

Section 1 of 4

✦ Skip the page breaks and see fewer ads — read each lesson on a single page with Pro

Cosmos DB API Selection Guide

Introduction

Azure Cosmos DB is a globally distributed, multi-model database service. Unlike traditional databases that force you into a single data model, Cosmos DB offers multiple APIs to interact with your data. This "multi-model" capability is one of its greatest strengths—and its greatest point of confusion for architects.

Choosing the right API is the most critical decision in your design phase. Once you commit to an API, migrating your data model to a different one later can be expensive and complex. This guide will help you navigate these options based on your application's data structure, query patterns, and existing ecosystem.


Understanding the API Options

Cosmos DB supports five primary APIs. Each is designed to handle specific data structures and developer workflows:

1. Core (SQL) API

The Core API is the native interface for Cosmos DB. It uses JSON as the storage format and SQL-like syntax for querying.

  • Best for: General-purpose applications, microservices, and scenarios requiring high-performance document storage.
  • Example: Storing user profiles, e-commerce product catalogs, or IoT sensor telemetry.

2. MongoDB API

This API provides wire-protocol compatibility with MongoDB. If you have an existing MongoDB application, you can migrate to Cosmos DB with minimal code changes.

  • Best for: Migrating existing MongoDB workloads or teams already familiar with the MongoDB driver ecosystem.

3. Cassandra API

This API provides compatibility with Apache Cassandra. It is designed for wide-column stores.

  • Best for: Time-series data, heavy write-throughput applications, and scenarios where you are already using Cassandra.

4. Gremlin (Graph) API

Designed for highly connected data, this API uses Apache TinkerPop to traverse relationships.

  • Best for: Social networks, recommendation engines, and fraud detection systems where the relationship between entities is as important as the entities themselves.

5. Table API

A key-value store designed for simple, fast lookups.

  • Best for: Simple data structures that do not require complex indexing or querying. It is the most cost-effective option for basic storage.

Section 1 of 4
PrevNext