SitecoreCDP.SDK
1.0.0-alpha3
See the version list below for details.
dotnet add package SitecoreCDP.SDK --version 1.0.0-alpha3
NuGet\Install-Package SitecoreCDP.SDK -Version 1.0.0-alpha3
<PackageReference Include="SitecoreCDP.SDK" Version="1.0.0-alpha3" />
paket add SitecoreCDP.SDK --version 1.0.0-alpha3
#r "nuget: SitecoreCDP.SDK, 1.0.0-alpha3"
// Install SitecoreCDP.SDK as a Cake Addin #addin nuget:?package=SitecoreCDP.SDK&version=1.0.0-alpha3&prerelease // Install SitecoreCDP.SDK as a Cake Tool #tool nuget:?package=SitecoreCDP.SDK&version=1.0.0-alpha3&prerelease
Sitecore CDP/Personalize SDK for .NET
The unofficial .Net SDK for Sitecore CDP/Personalize
Example
using SitecoreCDP.SDK;
// initialize client
var cdpClient = new CdpClient(new CdpClientConfig
{
ClientKey = "tenant-client-key",
ApiToken = "tenant-api-token",
BaseUrl = "https://api-engage-eu.sitecorecloud.io", // or "https://api.boxever.com"
Version = "v2"
});
// batch import
var batchRef = await cdpClient.BatchApi.UploadJson("import.json");
...
// check status
var status = await cdpClient.BatchApi.CheckStatus(batchRef);
if (status.Status.Code == BatchStatusCode.Error)
{
// download log and extract error records
var logRecords = await cdpClient.BatchApi.DownloadBatchLog(status.Status.LogUri);
var errorRecords = logRecords.Where(x => x.Code != 200);
}
Available services
At this moment Batch API, Interactive API and Audience Sync are ready. Stream API and Tenant API are in progress.
Batch API
Batch API is used to upload guests, orders, and tracking events. The are 3 types of supported import formats:
- Model based:
var batchRef = await cdpClient.BatchApi.Upload(new List<Batch>
{
new BatchGuest { Guest = new Guest() {/* populate fields */ } },
new BatchOrder {Order = new Order(){ /* populate fields */}},
...
});
- JSON file:
var batchRef = await cdpClient.BatchApi.UploadJson("import.json");
- GZip file:
var batchRef = await cdpClient.BatchApi.UploadGZip("import.json.gz");
Check batch import status and download error log in strongly typed records:
// check status
var status = await cdpClient.BatchApi.CheckStatus(batchRef);
if (status.Status.Code == BatchStatusCode.Error)
{
// download log and extract error records
var logRecords = await cdpClient.BatchApi.DownloadBatchLog(status.Status.LogUri);
var errorRecords = logRecords.Where(x => x.Code != 200);
}
AudienceSync API
AudienceSync REST API to trigger and retrieve batch jobs, download output files.
var triggerResponse = await cdpClient.AudienceSyncApi.Trigger(flowRef, segmentRef, datasetDate);
var jobStatus = await cdpClient.AudienceSyncApi.CheckStatus(triggerResponse.Ref);
if (jobStatus.Status == TriggerResponseStatus.Success)
{
await cdpClient.AudienceSyncApi.GetOutputFiles(triggerResponse.Ref, "outputFiles.gz");
}
Interactive API (REST)
- Guest API:
cdpClient.InteractiveApi.Guests
- Guest Data extensions API:
cdpClient.InteractiveApi.GuestExtensions
- Orders API:
cdpClient.InteractiveApi.Orders
- OrderItems API:
cdpClient.InteractiveApi.OrderItems
Stream API
In progress.
await cdpClient.StreamApi.RunExperiment(friendlyId);
await cdpClient.StreamApi.IdentifyUser(new IdentityEvent{});
await cdpClient.StreamApi.TrackEvent(new Event{});
await cdpClient.StreamApi.CreateNewSession();
await cdpClient.StreamApi.AbandonSession();
Tenant API
In progress.
FAQ
Do I have to use async
/await
when calling endpoints?
Yes. The SDK uses HttpClient
, which does not support synchronous calls (and for good reason). Do not use .Result
or .Wait()
on calls made with this SDK, ever. These will block threads and potentially cause deadlocks. In short, don't block on async code. Use await
.
Supported Platforms
The SDK is available with .NET 7.0, .NET Framework 4.6.x and .NET Standard 2.x that makes it compatible with almost all .NET solutions.
Getting Help
For programming questions you can ask me in Sitecore Slack channels @x3mxray.
To report a bug or request a feature specific to the SDK, please open an issue.
Helpful Resources
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 is compatible. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- Microsoft.Bcl.AsyncInterfaces (>= 6.0.0)
- System.Net.Http (>= 4.3.4)
- System.Text.Json (>= 6.0.0)
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
-
net7.0
- No dependencies.
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.7 | 101 | 6/4/2024 |
1.0.6 | 317 | 5/15/2024 |
1.0.5 | 221 | 3/20/2024 |
1.0.4 | 188 | 3/6/2024 |
1.0.3 | 129 | 1/16/2024 |
1.0.2 | 210 | 12/26/2023 |
1.0.1 | 412 | 6/6/2023 |
1.0.0 | 146 | 5/16/2023 |
1.0.0-alpha3 | 204 | 5/15/2023 |
1.0.0-alpha2 | 129 | 5/7/2023 |
1.0.0-alpha | 127 | 5/7/2023 |