Azure Cosmos DB

SQL API SDK - Unleash Your Data's Potential

Build Global, Scalable Apps

Effortlessly interact with your Azure Cosmos DB SQL API data using our robust and efficient SDKs.

Empower Your Applications

What is the SQL API?

The SQL API in Azure Cosmos DB provides a familiar query experience, akin to SQL, for accessing and manipulating your JSON data. It's the most popular API for its ease of use and powerful querying capabilities.

Why Use the SDK?

Our Software Development Kits (SDKs) are optimized to provide a seamless, high-performance interface to Cosmos DB. They handle complex operations like connection management, retries, and serialization, allowing you to focus on your application logic.

Performance & Scalability

Designed for modern cloud-native applications, the SQL API SDKs are built for low latency and high throughput, scaling automatically with your demands.

Key Features of the SQL API SDK

CRUD Operations

Easily perform Create, Read, Update, and Delete operations on your documents.

Rich Querying

Leverage a powerful SQL-like query language with support for joins, aggregations, and complex filtering.

Indexing

Benefit from automatic indexing of all your data with custom indexing policies for fine-tuned performance.

Change Feed

Process real-time data modifications with the Change Feed, enabling event-driven architectures.

Stored Procedures & Triggers

Encapsulate business logic directly within Cosmos DB for atomic operations and custom workflows.

Multi-Region Writes

Ensure high availability and low latency globally with multi-master replication.

Available SDKs

Choose the SDK that best fits your development ecosystem.

.NET SDK

For C#, .NET Core, and .NET Framework applications.

Java SDK

Integrate seamlessly with your Java-based applications.

Node.js SDK

Build scalable applications with JavaScript or TypeScript.

Python SDK

Leverage the power of Python for data interaction.

Go SDK

High-performance applications with the Go language.

JavaScript (Browser) SDK

Directly interact with Cosmos DB from your web applications.

Getting Started Quickly

1. Create a Cosmos DB Account

Set up your Azure Cosmos DB account with the SQL API enabled. You can do this via the Azure portal, Azure CLI, or ARM templates.

2. Install the SDK

Add the appropriate SDK package to your project using your language's package manager (e.g., NuGet, Maven, npm, pip).

3. Connect to Your Database

Use your Cosmos DB endpoint and primary key to establish a connection to your database and containers.

// Example using Node.js SDK const CosmosClient = require("@azure/cosmos").CosmosClient; const endpoint = "YOUR_COSMOS_DB_ENDPOINT"; const key = "YOUR_COSMOS_DB_PRIMARY_KEY"; const client = new CosmosClient({ endpoint, key }); const databaseId = "ToDoList"; const containerId = "Items"; async function createItem() { const { database } = await client.databases.createIfNotExists({ id: databaseId }); const { container } = await database.containers.createIfNotExists({ id: containerId }); const newItem = { id: "unique-item-id-1", category: "personal", name: "groceries", isComplete: false }; const { resource: createdItem } = await container.items.create(newItem); console.log(`Created item with id: ${createdItem.id}`); } createItem().catch(error => { console.error("An error occurred:", error); });

4. Perform Operations

Begin interacting with your data using the SDK's methods for querying, creating, updating, and deleting items.

Comprehensive API Reference

SDK Documentation & API Guides