Crews.PlanningCenter.Api 1.1.0

Prefix Reserved
dotnet add package Crews.PlanningCenter.Api --version 1.1.0                
NuGet\Install-Package Crews.PlanningCenter.Api -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crews.PlanningCenter.Api" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crews.PlanningCenter.Api --version 1.1.0                
#r "nuget: Crews.PlanningCenter.Api, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Crews.PlanningCenter.Api as a Cake Addin
#addin nuget:?package=Crews.PlanningCenter.Api&version=1.1.0

// Install Crews.PlanningCenter.Api as a Cake Tool
#tool nuget:?package=Crews.PlanningCenter.Api&version=1.1.0                

.NET Planning Center API Library

A client library for the Planning Center API built on the JSON:API Framework.

Installation

Crews.PlanningCenter.Api is available on NuGet:

dotnet add package Crews.PlanningCenter.Api

Setup with Dependency Injection

How you set up dependency injection depends on how you want to configure the service.

This library uses the options pattern. Options are defined in the PlanningCenterApiOptions class.

The following are valid options for configuring the service:

Option Name Type Required Description Default
ApiBaseAddress Uri No The base URL of the Planning Center API. https://api.planningcenteronline.com
PersonalAccessToken PlanningCenterPersonalAccessToken Yes The access token used to authenticate with the API. N/A
HttpClientName string No The name of a named HttpClient to use in the service.<br><br>NOTE: This client's BaseAddress property will be ignored in favor of the ApiBaseAddress option. N/A

You can automatically configure the service with the provider of your choice. Here's an example using appsettings.json:

{
	"PlanningCenterApi": {
		"ApiBaseAddress": "https://api.planningcenteronline.com",
		"PersonalAccessToken": {
			"AppID": "yourAppId",
			"Secret": "yourSecret"
		},
		"HttpClientName": "myCustomClient"
	}
}

Then, in Program.cs or Startup.cs:

using Crews.PlanningCenter.Api.DependencyInjection;

// ...

builder.Services.AddPlanningCenterApi();

Hardcoded Configuration

You can also configure the service using a lambda expression during service registration:

using Crews.PlanningCenter.Api.DependencyInjection;

// ...

builder.Services.AddPlanningCenterApi(options =>
{
	options.ApiBaseAddress = new("https://api.planningcenteronline.com");
	options.PersonalAccessToken = new()
	{
		AppID = "yourAppId",
		Secret = "yourSecret"
	};
	options.HttpClientName = "myCustomClient";
});

Basic Setup (Without Dependency Injection)

Start by creating an HttpClient instance:

using Crews.Extensions.Http;
using Crews.PlanningCenter.Api.Clients;
using Crews.PlanningCenter.Api.Models;

HttpClient client = new();
client.SafelySetBaseAddress(new("https://api.planningcenteronline.com"));

// Don't forget to add your access token!
PlanningCenterPersonalAccessToken token = new()
{
	AppID = "yourAppIdHere",
	Secret = "superSecretPasswordHere"
};
client.DefaultRequestHeaders.Authorization = token;

Use this HttpClient to create a new API client of your choice, and you're off to the races!

CalendarClient calendar = new(client);

var myEvent = await calendar.LatestVersion.Events.WithID("123").GetAsync();
Console.WriteLine($"My event is called {myEvent.Data.Name}!");

Usage Examples

Fluent API Example

You can chain API resource calls to navigate the API:

var myEvent = await calendar.LatestVersion
	.Events
	.WithID("123")
	.Owner
	.EventResourceRequests
	.WithID("456")
	.ResourceBookings
	.WithID("789")
	.EventInstance
	.Event
	.GetAsync();

Querying Example

You can easily include related resources, or sort and query collections:

var myAttachments = await calendar.LatestVersion.Attachments
	.Include(AttachmentIncludable.Event)
	.OrderBy(AttachmentOrderable.FileSize, Order.Descending)
	.Query((AttachmentQueryable.Name, "myAttachment"), (AttachmentQueryable.Description, "The best attachment."))
	.GetAllAsync();

// Reading included resources must be done manually.
var includedResources = myAttachments.JsonApiDocument.GetIncludedResources();

Pagination Example

You can specify a count and an offset for collections of resources:

var myAttachments = await calendar.LatestVersion.Attachments.GetAllAsync();

Console.WriteLine(myAttachments.Metadata.TotalCount);  // Get total count of items available on the API
Console.WriteLine(myAttachments.Metadata.Next.Offset);  // Get item offset for next page of items

// Get only first five items
myAttachments = await calendar.LatestVersion.Attachments.GetAllAsync(count: 5);

// Get ten items, offset by five items
myAttachments = await calendar.LatestVersion.Attachments.GetAllAsync(count: 10, offset: 5);

Mutation Example

You can also POST, PATCH, and DELETE resources with these options:

var myEventConnection = calendar.LatestVersion
	.Events
	.WithID("123")
	.EventConnections
	.WithID("456");

EventConnection newConnection = new()
{
	ConectedToId = "123",
	ConnectedToName = "Test"
};

var postResult = await myEventConnection.PostAsync(newConnection);   // POST
var patchResult = await myEventConnection.PatchAsync(newConnection); // PATCH
await myEventConnection.DeleteAsync();                               // DELETE

S.D.G.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 32 1/23/2025
1.0.2 72 1/15/2025
1.0.0-preview.14 59 12/6/2024
1.0.0-preview.13 54 11/30/2024
1.0.0-preview.12 51 11/29/2024
1.0.0-preview.11 68 11/11/2024
1.0.0-preview.10 63 11/11/2024
1.0.0-preview.9 55 11/9/2024
1.0.0-preview.8 59 11/9/2024
1.0.0-preview.7 59 10/16/2024
1.0.0-preview.6 63 10/15/2024
1.0.0-preview.5 60 10/3/2024
1.0.0-preview.4 52 10/3/2024
1.0.0-preview.3 65 9/25/2024
1.0.0-preview.2 72 5/22/2024
1.0.0-preview.1 69 5/22/2024