Skip to main content

Apple Pass Generator

Python library to generate passes i.e (.pkpass) files compatible with Apple Wallet (former Passbook).

Table of Contents

💾 Installation

To easily install or upgrade to the latest release, use pip.

$ pip install applepassgenerator

🍎 Apple docs

From now on, some stuff is much better explained on the Apple docs, so when in doubt just check (if you haven't done so) the following documents:

📝 Configuration

To start using the lib, some Apple files are needed, as well as some action in order to convert them to more friendly formats:

  • Get Pass Type ID

    • Go to the Apple Developer page ➵ Identifiers ➵ Pass Type IDs.
    • Next, you need to create a pass type ID. This is similar to the bundle ID for apps. It will uniquely identify a specific kind of pass. It should be of the form of a reverse-domain name style string (i.e., pass.com.example.appname).
  • Generate the necessary certificate

    • After creating the pass type ID, click on Edit and follow the instructions to create a new Certificate.

    • Once the process is finished, the pass certificate can be downloaded. That's not it though, the certificate is downloaded as .cer file, which need to be converted to .p12 in order to work. If you are using a Mac you can import it into Keychain Access and export it as .p12from there.

    • if now you have certificate.p12 file follow the steps below to convert it to certifictate.pem

      $ openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.pem
      
  • Generate the key.pem

    >$ openssl pkcs12 -in certificate.p12 -nocerts -out private.key
    

    Note: While generating this private.key file you will be asked for a PEM pass phrase which will be used as the CERTIFICATE_PASSWORD attribute throughout the Package.

  • Getting WWDR Certificate

    • If you have made iOS development, you probably have already the Apple Worldwide Developer Relations Intermediate Certificate in your Mac’s keychain.
    • If not, it can be downloaded from the Apple Website (on .cer format). This one needs to be exported as .pem, It can be exported from KeyChain into a .pem (e.g. wwdr.pem).

🚀 Usage

from applepassgenerator import ApplePassGeneratorClient
from applepassgenerator.models import EventTicket

card_info = EventTicket()
card_info.add_primary_field('name', 'Tony Stark', 'Name')
card_info.add_secondary_field('loc', 'USA', 'Country')

team_identifier = "1234ABCDEF"
pass_type_identifier = "pass.com.project.example"
organization_name = "Primedigital Global"

applepassgenerator_client = ApplePassGeneratorClient(team_identifier, pass_type_identifier, organization_name)
apple_pass = applepassgenerator_client.get_pass(card_info)

# Add logo/icon/strip image to file
apple_pass.add_file("logo.png", open("<path>/logo.png", "rb"))
apple_pass.add_file("icon.png", open("<path>/icon.png", "rb"))

CERTIFICATE_PATH = "<path-to-file>/certificate.pem"
PASSWORD_KEY = "<path-to-file>/password.key"
WWDR_CERTIFICATE_PATH = "<path-to-file>/wwdr.pem"
CERTIFICATE_PASSWORD = "<password>"
OUTPUT_PASS_NAME = "mypass.pkpass"

apple_pass.create(CERTIFICATE_PATH, PASSWORD_KEY, WWDR_CERTIFICATE_PATH, CERTIFICATE_PASSWORD, OUTPUT_PASS_NAME)

Code of Conduct

In order to foster a kind, inclusive, and harassment-free community, we have a code of conduct, which can be found here. We ask you to treat everyone as a smart human programmer that shares an interest in Python and Apple Pass Generator with you.

Release files for applepassgenerator 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for applepassgenerator 0.0.2
File Size Uploaded
applepassgenerator-0.0.2.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for applepassgenerator 0.0.2
File Interpreter ABI Platform
applepassgenerator-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / applepassgenerator-0.0.2.tar.gz

Download URL applepassgenerator-0.0.2.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
36eda47974472592f5cb61ee5ebdd756808eecf519659bd5faccf3fb6a199f4b
BLAKE2b-256 checksum
How to use checksums
6d6821259fc09e31d84e3cceefe9fa9a06ca1760a48a136230cf1c7070f1e672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1033-azure

Release files / applepassgenerator-0.0.2-py3-none-any.whl

Download URL applepassgenerator-0.0.2-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07b4d88ecc7b3102662b83fc79090c13ee76484a69ac1eeb7550cba54d1e3ecd
BLAKE2b-256 checksum
How to use checksums
ec2c566a7a398fd446d3c73f91dcf0592178897a162d710d38cc9f47bc98ae81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1033-azure

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page