Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Get started

How to get started with the Optimizely Graph .NET Source SDK.

📘

Note

Optimizely Graph .NET Source SDK is optimized for CMS 12.

Optimizely Graph .NET Source SDK streamlines the configuration and setup process of Optimizely Graph for developers. The SDK serves as a C# wrapper around the Optimizely Graph API and abstracts the details of API communication and data handling. It lets you configure content types, build datasets, and sync content with Optimizely Graph using C#.

The SDK integrates into any .NET back-end application. Push data from external sources to provide a flexible content management solution for all business requirements.

See the Introducing Optimizely Graph Source .NET SDK blog for information.

Access the SDK

The SDK is open source and available on GitHub.

Configure the client

To begin, initialize a new instance of the GraphSourceClient by invoking the static Create method. Pass in your base URL, Optimizely Graph source, application key, and secret, as shown in the following code sample:

var client = GraphSourceClient.Create(
    new Uri("https://cg.optimizely.com"),
    "SOURCE",
    "APPLICATION_KEY",
    "SECRET"
);

How to find your credentials depends on what type of project you have:

  • Development environment or self-hosted CMS – Optimizely emails your credentials using a one-time secret.
  • Digital Experience Platform (DXP) – View your credentials in the DXP portal (PaaS portal).
  • CMS (SaaS) – View your credentials in the Dashboard.

When your client is initialized, configure content types using any C# class object. This integration lets you manage content within your existing application’s codebase.

Example: cafe menu structure

For example, a cafe needs to configure content for its menu. With the .NET Source SDK, you can model the menu structure using C# classes. The following is a sample class definition for a cafe:

public class Cafe
{
    public string Name { get; set; }

    public DateTime Established { get; set; }

    public Location Address { get; set; }

    public Menu Menu { get; set; }
}

public class Location
{
    public string City { get; set; }

    public string State { get; set; }
    
    public string Zipcode { get; set; }

    public string Country { get; set; }  
}

public class Menu
{
    public Beverage Beverage { get; set; }

    public Food Food { get; set; }
}

public class Beverage
{
    public string Name { get; set; }

    public double Price { get; set; }

    public List<string> Sizes { get; set; }

}

public class Food
{
    public string Name { get; set; }

    public double Price { get; set; }

    public bool IsAvailable { get; set; }
}

By handling the configuration, the .NET Source SDK lets you focus on building high-performance applications while managing data effectively.

Next steps

After initializing and configuring your .NET Source SDK, define and manage content types. See Content types for how to configure content types and use different index types for data retrieval and management.