Introduction to Azure Cosmos DB APIs
Azure Cosmos DB is a globally distributed, multi-model database service. It offers a variety of APIs, allowing you to use the data model and API that best suits your application's needs. This page provides an overview of the different APIs available and links to detailed documentation.
Choosing the right API is crucial for optimizing performance, development effort, and compatibility with existing tools and frameworks. Azure Cosmos DB supports multiple APIs, each designed for different use cases and data paradigms.
REST API
The Azure Cosmos DB REST API is the foundation upon which all other APIs are built. It provides direct access to all Cosmos DB resources, including databases, collections, documents, and stored procedures. You can use this API to perform CRUD (Create, Read, Update, Delete) operations, manage throughput, and configure policies.
Key Features:
The REST API is ideal for scenarios where you need fine-grained control or are integrating with custom client libraries.
SQL (Core) API
The SQL API, also known as the Core API, is the native API for Azure Cosmos DB. It provides a rich, schema-agnostic data model and a powerful SQL query language that is familiar to developers working with relational databases. It offers the highest performance and richest feature set within Cosmos DB.
Key Features:
Use the SQL API for new applications or when migrating from document databases or relational databases where a SQL-like interface is preferred.
MongoDB API
The MongoDB API allows you to use your existing MongoDB drivers and tools with Azure Cosmos DB. This API provides a fully managed, globally distributed MongoDB-compatible database service, enabling you to leverage the benefits of Cosmos DB without rewriting your application code.
Key Features:
Ideal for migrating existing MongoDB applications to a cloud-native, globally distributed platform.
Cassandra API
The Cassandra API offers a Cassandra-compatible data model and query language (CQL). It allows you to leverage the benefits of Azure Cosmos DB, such as global distribution, elastic scalability, and turnkey replication, while using your familiar Cassandra tools and applications.
Key Features:
Migrate your Cassandra workloads to Azure for enhanced scalability, reliability, and managed operations.
Gremlin API
The Gremlin API is built for graph data. It supports the Apache TinkerPop Gremlin traversal language, enabling you to build applications with complex relationships and graph traversals. This API is ideal for scenarios involving social networks, recommendation engines, fraud detection, and knowledge graphs.
Key Features:
Build powerful graph-based applications and analyze complex relationships with ease.
Table API
The Table API provides a key-value store and schema-less design, similar to Azure Table Storage but with the added benefits of Cosmos DB's global distribution, elasticity, and advanced indexing capabilities. It's suitable for applications requiring high throughput and low latency for simple data operations.
Key Features:
An excellent choice for migrating existing Azure Table Storage applications or for new projects requiring a simple, scalable NoSQL store.
SDKs
Azure Cosmos DB provides official SDKs for various programming languages to simplify interaction with its APIs. These SDKs abstract the underlying REST API calls, offering a more convenient and type-safe development experience.
Available SDKs:
We recommend using the appropriate SDK for your chosen language to streamline development and leverage the full capabilities of Azure Cosmos DB.
Code Examples
Explore practical code examples demonstrating how to use the various Azure Cosmos DB APIs and SDKs. These examples cover common scenarios like creating documents, querying data, and managing resources.
Sample Scenarios:
Dive into the examples to quickly get started building your Cosmos DB-powered applications.