Skip to main content

Apple CloudKit server-to-server support for the requests Python library.

Project description

This project provides Apple CloudKit server-to-server support for the requests Python library.

Installation

requests-cloudkit is available for download through the Python Package Index (PyPi). You can install it right away using pip or easy_install.

pip install requests-cloudkit

Usage

requests-cloudkit provides an authentication object that can be passed directly to requests to authenticate calls to the CloudKit API. Before working with the CloudKit server-to-server API, you’ll first need to follow Apple’s instructions to generate a certificate and a server-to-server key (see Accessing CloudKit Using a Server-to-Server Key).

Once you have these values, just plug them into a CloudKitAuth object, which you can use with requests interface with CloudKit. E.g.:

>>> import requests
>>> from requests_cloudkit import CloudKitAuth
>>> auth = CloudKitAuth(key_id=YOUR_KEY_ID, key_file_name=YOUR_PRIVATE_KEY_PATH)
>>> requests.get("https://api.apple-cloudkit.com/database/[version]/[container]/[environment]/public/zones/list", auth=auth)

requests-cloudkit can also be used with RestMapper to integrate directly with the CloudKit API.

>>> CloudKit = restmapper.RestMapper("https://api.apple-cloudkit.com/database/[version]/[container]/[environment]/")

Instantiate a cloudkit instance using your CloudKit server-to-server key ID and provide the path to the private key file.

>>> cloudkit = CloudKit(auth=CloudKitAuth(key_id=YOUR_KEY_ID, key_file_name=YOUR_KEY_FILE))

Now, you can start making requests to the CloudKit API using a nice attribute syntax.

>>> response = cloudkit.public.zones.list()

…will hit https://api.apple-cloudkit.com/database/[version]/[container]/[environment]/public/zones/list.

If you want to pass in body data for a POST, provide a single argument to the call to the API, and specify “POST” as the first attribute. I.e.

>>> cloudkit.POST.my.request(data)

For the full list of CloudKit Server-to-Server API capabilities, reference Apple’s developer documentation.

Support

If you like this library, or need help implementing it, send me an email: dan@lionheartsw.com.

License

http://img.shields.io/pypi/l/requests-cloudkit.svg?style=flat

Apache License, Version 2.0. See LICENSE for details.

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

requests-cloudkit-0.1.2.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file requests-cloudkit-0.1.2.tar.gz.

File metadata

File hashes

Hashes for requests-cloudkit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5983704b38f27b36971f93b8a1335d424cc57555f8fabb08316d1723f4a284f3
MD5 5137fcccd27dff1fb88c70dd4a2cbcd1
BLAKE2b-256 fc86ef5ce495808d1c2c498a1de43dd67fb70797968bdb07ca1c7f319e142add

See more details on using hashes here.

Supported by

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