---
title: Quick start with the Graph C# SDK
slug: cms-13/docs/quick-start
docTags: 
createdAt: 2026-07-30T20:22:07.892Z
---

Use the Graph C# SDK to query content from Optimizely Graph with a strongly typed, LINQ-style API in .NET applications. This guide shows how to install the SDK, configure authentication, and run your first query.

## Prerequisites

Before you begin, confirm that you have the following:

- .NET 10.0 or later.
- An Optimizely Graph instance with an `AppKey` and `Secret` from the Graph portal.
- Content synchronized to Optimizely Graph.

If content is not synchronized yet, run the **Graph Full Synchronization** scheduled job in CMS.

## Install the package

Install the core query package:

```bash
dotnet add package Optimizely.Graph.Cms.Query
```

## Configure your credentials

Add your Graph endpoint and credentials to `appsettings.json`:

```json
{
  "Optimizely": {
    "Graph": {
      "Endpoint": "https://cg.optimizely.com",
      "AppKey": "YOUR_APP_KEY",
      "Secret": "YOUR_SECRET_KEY"
    }
  }
}
```

:::hint{type="danger"}
**Important**
Do not commit `Secret` to source control. Store credentials in environment variables or a secure secrets manager in production.
:::

## Write your first query

Inject `IGraphContentClient` into your controller and call `QueryContent<T>()` to retrieve content. The following example queries `BlogPostPage` items by author:

```csharp
public class MyController : Controller
{
    private readonly IGraphContentClient _graphClient;

    public MyController(IGraphContentClient graphClient)
    {
        _graphClient = graphClient;
    }

    public async Task<IActionResult> Index()
    {
        var result = await _graphClient
            .QueryContent<BlogPostPage>()
            .Where(x => x.Author == "John Developer")
            .Limit(10)
            .GetAsContentAsync();

        return View(result);
    }
}
```

`GetAsContentAsync()` returns an `IGetAsContentResult<T>`, which implements `IEnumerable<T>`. Iterate over the returned content items directly.

## Common issues on first run

The following table lists common problems and their solutions when running the SDK for the first time.

| Issue                              | Resolution                                                                         |
| ---------------------------------- | ---------------------------------------------------------------------------------- |
| `401 Unauthorized`                 | Check `AppKey` and `Secret` in `appsettings.json`.                                 |
| Empty results                      | Verify content is published and the Graph Full Synchronization job has run.        |
| `IGraphContentClient` not resolved | Confirm that the package is installed and dependency injection (DI) is configured. |

## Next steps

Now that you have a working query, explore the rest of the SDK:

- [Authentication requests in C# SDK](docId:7S9dTMUKYWTDBF6Vs0grs) – Single Key versus Basic authentication
- [Filter Optimizely Graph results with the C# SDK](docId\:f0IXlPPYtzSZ9ySIUEu6K) – filter by string, numeric, boolean, and date fields
- [Search content in Optimizely Graph with the C# SDK](docId\:wkIAHH2c8t0jVgJpquxTS) – full-text search with field boosting
- [Paginate Optimizely Graph results with the C# SDK](docId\:W3aOzwcLJHZ_-OYEdo1M6) – `Skip` and `Limit` for large result sets
- [Aggregate Optimizely Graph results with the C# SDK](docId:_B9t8PFTxIhFThrub7yqk) – facets for category-based filtering
- [Search tracking](docId\:wzB3gTVamNCXBp17QrLo5) – track which results users click
