PINGWorks.SitecoreAI.ComponentsSDK
1.0.0
dotnet add package PINGWorks.SitecoreAI.ComponentsSDK --version 1.0.0
NuGet\Install-Package PINGWorks.SitecoreAI.ComponentsSDK -Version 1.0.0
<PackageReference Include="PINGWorks.SitecoreAI.ComponentsSDK" Version="1.0.0" />
<PackageVersion Include="PINGWorks.SitecoreAI.ComponentsSDK" Version="1.0.0" />
<PackageReference Include="PINGWorks.SitecoreAI.ComponentsSDK" />
paket add PINGWorks.SitecoreAI.ComponentsSDK --version 1.0.0
#r "nuget: PINGWorks.SitecoreAI.ComponentsSDK, 1.0.0"
#:package PINGWorks.SitecoreAI.ComponentsSDK@1.0.0
#addin nuget:?package=PINGWorks.SitecoreAI.ComponentsSDK&version=1.0.0
#tool nuget:?package=PINGWorks.SitecoreAI.ComponentsSDK&version=1.0.0
PINGWorks.SitecoreAI.ComponentsSDK
This is a .NET SDK for working with SitecoreAI's Components API.<br /> More information about Sitecore's API is at Components API Doc (official)
Features
- Typed, DI-friendly service for interacting with the SitecoreAI Components API
- Async-first API with
CancellationTokensupport and full XML documentation comments - NetStandard 2.1 for wide compatibility
- Automatic token maintenance using client credentials flow
- Optional
environmentIdparameter on every operation, for targeting specific environments
Getting started
Prerequisites
To work with the SDK you will require credentials which are created in the SitecoreAI Deployment Portal.
Create an Environment credential of type Automation for the project and environment combination for which you wish to grant access.
Install
From your project directory:
dotnet add package PINGWorks.SitecoreAI.ComponentsSDK
AppSettings
Properties are available to configure the SDK through configuration binding. The snippet below shows all options along with their default values. You do not need to include values where you wish to use the defaults.
{
/* The base URL of the Components API */
"ServiceEndpoint": "https://edge-platform.sitecorecloud.io/authoring/api/v1/",
/* The URL of the Token Request API */
"TokenEndpoint": "https://auth.sitecorecloud.io/oauth/token",
/* The auth audience */
"Audience": "https://api.sitecorecloud.io",
/* The auth grant type */
"GrantType": "client_credentials",
/* The value of ClientID from the SitecoreAI Deploy Portal */
"ClientID": "[Created in SitecoreAI Deploy portal's Credentials pane]",
/* The value of ClientSecret from the SitecoreAI Deploy Portal */
"ClientSecret": "[Created in SitecoreAI Deploy portal's Credentials pane]"
}
We recommend the use of Visual Studio's User Secrets feature to store sensitive information such as ClientId and ClientSecret during development.
Register services
Register the SDK in Program.cs, e.g. when using the minimal hosting model:
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// Register SDK services - set options through binding or manually
builder.Services.AddSitecoreEEComponentsSDK( opt => config.GetSection( "mySettings" ).Bind( opt ) );
HttpClient defaults. This call (via
AddSitecoreEECommon) appliesAddStandardResilienceHandler()and a DEBUG-only console request/response logger to every HttpClient in your container — not just the SDK's own. See the PINGWorks.SitecoreExperienceEdge.Common README for how to customize the resilience options per-client.
Shared credentials. This SDK shares one
DefaultTokenProviderwith the other SitecoreAI and Experience Edge SDKs and uses the credentials of the last SDK registered, so configure the same automation client for all of them in one container. The Transfer SDK uses its own per-environment credentials.
This library uses Json serialization through System.Text.Json.
Using the environment ID
Every operation accepts an optional environmentId parameter that targets a specific SAI environment. When omitted, the default environment is used.
// Target a specific environment
var components = await sdk.ListComponents( environmentId: "main" );
Identifiers
Identifier parameters are strings. Plain GUIDs and braced upper-case GUIDs ({110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}) are both accepted and are sent as given.
Drafts
A component draft is created with CreateDraft, built up with UpdateDraft (partial) or ReplaceDraft (full), and turned into a component with ActivateDraft, naming the variants to activate.
var draft = await sdk.CreateDraft( new CreateComponentDraftInput { Name = "Hero", Type = DraftType.Code } );
if ( !draft.IsSuccessful ) return;
await sdk.UpdateDraft( draft.Result.Id!, new UpdateComponentDraftInput {
Variants = [ new ComponentVariantDraft { Name = "Default", Code = "export default function Hero() { ... }" } ]
} );
await sdk.ActivateDraft( draft.Result.Id!, new ActivateComponentDraftInput { VariantNames = [ "Default" ] } );
Errors
A failed call returns an ApiResponse<T> with IsSuccessful == false and an Error (RFC 7807 problem details: Title, Detail, Status).
Available services
Injectable interface ISitecoreComponentsSdk
Components
| Method | Description |
|---|---|
ListComponents(siteId?, environmentId?) |
Lists components. |
CreateComponent(request, environmentId?) |
Creates a component. |
ListComponentSummaries(siteId?, environmentId?) |
Lists lightweight component summaries. |
GetComponent(componentId, siteId?, environmentId?) |
Retrieves a component. |
UpdateComponent(componentId, request, environmentId?) |
Partially updates a component. |
GetComponentMetadata(componentId, siteId, contextItemId, renderingHostName, componentName?, environmentId?) |
Retrieves a component's metadata for a site. |
GetComponentVariantMetadata(componentId, componentVariantId, siteId, environmentId?) |
Retrieves a component variant's metadata. |
ListComponentSites(componentId, environmentId?) |
Lists the sites a component is available to. |
Drafts
| Method | Description |
|---|---|
ListDrafts(environmentId?) |
Lists component drafts. |
CreateDraft(request, environmentId?) |
Creates a component draft. |
GetDraft(componentDraftId, environmentId?) |
Retrieves a component draft. |
UpdateDraft(componentDraftId, request, environmentId?) |
Partially updates a component draft. |
ReplaceDraft(componentDraftId, request, environmentId?) |
Replaces a component draft. |
DeleteDraft(componentDraftId, environmentId?) |
Deletes a component draft. |
CreateDraftModelSuggestion(id, request, environmentId?) |
Generates a content type draft suggestion using AI. |
ActivateDraft(componentDraftId, request, environmentId?) |
Activates a draft, creating the component. |
CreateDraftSuggestion(request, environmentId?) |
Generates a component draft suggestion from a prompt using AI. |
Categories
| Method | Description |
|---|---|
ListCategories(environmentId?) |
Lists component categories. |
ListCategoryComponents(category, environmentId?) |
Lists the components in a category. |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Http (>= 10.0.5)
- Microsoft.Extensions.Http.Resilience (>= 10.4.0)
- PINGWorks.SitecoreExperienceEdge.Common (>= 1.3.1)
- System.Net.Http.Json (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 99 | 11/30/2026 |
v1.0.0 Initial release