SQL API SDK - Unleash Your Data's Potential
Effortlessly interact with your Azure Cosmos DB SQL API data using our robust and efficient SDKs.
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.
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.
Designed for modern cloud-native applications, the SQL API SDKs are built for low latency and high throughput, scaling automatically with your demands.
Easily perform Create, Read, Update, and Delete operations on your documents.
Leverage a powerful SQL-like query language with support for joins, aggregations, and complex filtering.
Benefit from automatic indexing of all your data with custom indexing policies for fine-tuned performance.
Process real-time data modifications with the Change Feed, enabling event-driven architectures.
Encapsulate business logic directly within Cosmos DB for atomic operations and custom workflows.
Ensure high availability and low latency globally with multi-master replication.
Choose the SDK that best fits your development ecosystem.
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.
Add the appropriate SDK package to your project using your language's package manager (e.g., NuGet, Maven, npm, pip).
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);
});
Begin interacting with your data using the SDK's methods for querying, creating, updating, and deleting items.