Azure Cosmos DB API Reference

This section provides detailed reference documentation for the various APIs available in Azure Cosmos DB. Azure Cosmos DB is a globally distributed, multi-model database service that enables you to create highly scalable and globally distributed applications. It supports multiple data models and APIs, including SQL (Core) API, MongoDB API, Cassandra API, Gremlin API, and Table API.

Core (SQL) API

The Core (SQL) API is the native API for Azure Cosmos DB. It provides a rich set of features for managing JSON documents, including powerful querying capabilities using SQL.

REST API Reference

The Azure Cosmos DB REST API allows you to interact with your Cosmos DB accounts programmatically. You can perform operations such as creating, reading, updating, and deleting resources like databases, containers, and items.

Key resources include:

For detailed endpoint definitions and request/response formats, please refer to the official Microsoft Azure REST API documentation.

SDK Reference (C#, Java, Node.js, Python, .NET)

Our Software Development Kits (SDKs) provide a more intuitive and productive way to interact with Azure Cosmos DB from your applications. They abstract away the complexities of the REST API and offer language-specific interfaces.

.NET SDK

The .NET SDK allows you to work with Azure Cosmos DB using C#. It offers classes and methods for managing containers, items, and executing queries.


using Microsoft.Azure.Cosmos;

// ... setup CosmosClient ...

// Example: Create a container
await database.CreateContainerIfNotExistsAsync("myContainer", "/partitionKey");
            

View .NET SDK Documentation

Java SDK

The Java SDK provides similar functionality for Java developers.


import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosDatabase;

// ... setup CosmosClient ...

// Example: Read item
CosmosItemResponse<MyDocument> itemResponse = database.getContainer("myContainer")
    .getItem("itemId", "partitionKey").readItem(new ItemRequestOptions());
            

View Java SDK Documentation

Node.js SDK

For JavaScript and Node.js applications, the Node.js SDK is the preferred choice.


const { CosmosClient } = require("@azure/cosmos");

// ... setup CosmosClient ...

// Example: Query items
const { resources: items } = await container.items.query("SELECT * from c").fetchAll();
            

View Node.js SDK Documentation

Python SDK

The Python SDK offers a Pythonic way to interact with Azure Cosmos DB.


from azure.cosmos import CosmosClient

# ... setup CosmosClient ...

# Example: Upsert item
container.upsert_item(body={"id": "myDocId", "content": "new data"})
            

View Python SDK Documentation

Other APIs

Azure Cosmos DB also supports other popular NoSQL APIs:

MongoDB API

The MongoDB API allows you to use your existing MongoDB applications with Azure Cosmos DB without code changes. It provides compatibility with MongoDB wire protocol.

Learn more about MongoDB API

Cassandra API

The Cassandra API offers Apache Cassandra compatibility, enabling you to use your Cassandra applications with Azure Cosmos DB.

Learn more about Cassandra API

Gremlin API

The Gremlin API provides support for Apache TinkerPop and Gremlin, allowing you to build graph database solutions on Azure Cosmos DB.

Learn more about Gremlin API

Table API

The Table API offers Azure Table storage compatibility, providing a key-value store for semi-structured data.

Learn more about Table API

Note

Always refer to the official Microsoft Azure documentation for the most up-to-date and comprehensive API reference. This page provides an overview and links to key resources.