Skip to main content

Python wrappers for interacting with the Planning Center Online APIs

Project description

Build Status Coverage Status PyPI - Version

pco-python-sdk

A Python SDK for simplifying interactions with the Planning Center API.

NOTE: WIP. This library is not stable and is under active development. I will release a 1.x.x version when the library has reached a stable state.

Currently only supporting the latest version of all the APIs. Will come up with a better versioning strategy after 1.0

Need to install

poetry python ruff pre-commit

NOTE: Not currently supporting the json fields in the attribute payloads

Getting Started

Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

pip install planning_center_python

Contributing

TODO: Add dev instructions

This project is under active development. Feel free to contribute and submit a pull request. The project is managed with poetry and tests use pytest.

Docs

Webhooks

You can validate a webhook using the WebhookSignature class. Pass the request headers, the body of the request, and the secret to .verify which will return True/False depending if the signature is verified. A SignatureVerificationError will be raise for any exceptions.

Auth and Client Setup

There is a class called PCOToken that wraps the token dict returned from https://api.planningcenteronline.com/oauth/token. NOTE: The inital auth => redirect token fetch is not yet supported.

Once you have a token instance you need to initialize a set of credentials (Credentials). Credentials takes a client_id, client_secret, a pco_token, and a token_updater. token_updater is a callable function that takes one argument token and is used to store a new token whenever a token refresh is triggered.

Create an instance of a PCOClient using the Credentials and you are off and running. You can access api resources from the client.

from planning_center_python.api import PCOClient, Credentials, PCOToken

def token_saver(token):
    print(token)

client_id = "myclientid"
secret = "mysecretkey"
token = {
    "access_token": "pco_tok_abc",
    "token_type": "Bearer",
    "expires_in": 7199,
    "refresh_token": "abcdefg",
    "scope": ["people", "services"],
    "created_at": 1737307589,
    "expires_at": 1737314788.50569,
}
pco_token = PCOToken(token)
credentials = Credentials(
    client_id=client_id,
    client_secret=secret,
    pco_token=pco_token,
    token_updater=token_saver,
)
client = PCOClient(credentials=credentials)
person = client.person.get("personid")

NOTE: The client is a singleton. You only need to initialize it once with an http_client or credentials from then on you can call PCOClient() to return the already configured client.

The client also takes care of checking token expirations and will automatically refresh it using the refresh token in the credentials. After refreshing the token it will pass the new token to the function passed into the token_updater property so it can be saved if needed.

Contributing

Cutting a version

This repo contains semantic-release as a dev dependency. Review the changelog and ensure version notes are up to date (or that all commits in release have correct commit semantics).

Cut a new patch version.

bin/new-patch-version.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

planning_center_python-0.0.7.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

planning_center_python-0.0.7-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file planning_center_python-0.0.7.tar.gz.

File metadata

  • Download URL: planning_center_python-0.0.7.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for planning_center_python-0.0.7.tar.gz
Algorithm Hash digest
SHA256 ee6fb2376d36f47dd35e9b8634a223a0f1b62ac554de9fdd7e55d9a1ab96d645
MD5 4e5bb88fe9d1e55fc513a5b3b443c3ac
BLAKE2b-256 400ef822bb0ccf1fd7b3c3de734fe34d38927c1edc25d206862488da6a2346c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for planning_center_python-0.0.7.tar.gz:

Publisher: publish.yml on andy-goellner/pco-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file planning_center_python-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for planning_center_python-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 702418a39bb23cbcbc250fd74a6583cf210ba4e2b2fbcf442a51d408663859c0
MD5 8aa2ac3178ed912d63c75b2bb5c8434d
BLAKE2b-256 9c7d24022438c0236908a31071b8428e1bad7fa938d69557eb2ce79272de0825

See more details on using hashes here.

Provenance

The following attestation bundles were made for planning_center_python-0.0.7-py3-none-any.whl:

Publisher: publish.yml on andy-goellner/pco-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page