Cosmos DB APIs and SDK Implementation
Navigate Cosmos DB's five APIs, perform CRUD with the .NET SDK, implement optimistic concurrency with ETags, and write efficient queries — all the SDK patterns the AZ-204 exam tests.
# Cosmos DB APIs and SDK Implementation
*This article is Part 2, Chapter 2.2 of the **AZ-204 Exam Refresher** series. We move from architectural decisions to hands-on implementation — covering the five Cosmos DB APIs, SDK CRUD patterns, optimistic concurrency control, and querying.*
---
## Introduction
Knowing that Cosmos DB is a globally distributed database is one thing. Knowing how to *actually build with it* is another. The AZ-204 exam expects you to understand which API to choose for a given legacy migration scenario, and how to implement common patterns like optimistic concurrency using ETags.
The good news: once you've written the SDK code once, the patterns repeat. The SDK is well-designed and follows intuitive conventions.
---
## Core Concepts
### The Five Cosmos DB APIs
Cosmos DB is a multi-model database — the same underlying engine can be accessed through five different wire protocols, each targeting a different developer audience.
| API | Wire Protocol | Best Migration From | Key Use Case |
|---|---|---|---|
| **NoSQL (Core)** | Cosmos-native JSON | New projects | Flexible schema, full SDK features |
| **MongoDB** | MongoDB protocol | Existing MongoDB apps | Lift-and-shift MongoDB workloads |
| **Cassandra** | CQL (Cassandra Query Language) | Existing Cassandra apps | Wide-column, time-series data |
| **Gremlin** | Apache TinkerPop | Graph databases | Social networks, recommendations |
| **Table** | Azure Table Storage protocol | Existing Table Storage