Skip to main content

PassNinja API library for Python

Project description

passninja-python

Use passninja-python as a PyPi or Anaconda module.

Contents

Installation

Install via pip:

pip install passninja

Usage

PassNinjaClient

Use this class to create a PassNinjaClient object. Make sure to pass your user credentials to make any authenticated requests.

import passninja

account_id = '**your-account-id**'
api_key = '**your-api-key**'

pass_ninja_client = passninja.PassNinjaClient(account_id, api_key)

We've placed our demo user API credentials in this example. Replace it with your actual API credentials to test this code through your PassNinja account and don't hesitate to contact PassNinja with our built in chat system if you'd like to subscribe and create your own custom pass type(s).

For more information on how to use passninja-python once it loads, please refer to the PassNinja JS API reference

PassNinjaClientMethods

This library currently supports methods for creating, getting, updating, and deleting passes via the PassNinja api. The methods are outlined below.

Create

simple_pass_object = pass_ninja_client.passes.create(
    'ptk_0x14', # passType
    {'discount': '50%', 'memberName': 'John'} # passData
)
print(simple_pass_object.url)
print(simple_pass_object.passType)
print(simple_pass_object.serialNumber)

Find

Finds issued passes for a given pass template key

pass_objects = pass_ninja_client.passes.find(
    'ptk_0x14', # passType aka pass template key
)

Get

detailed_pass_object = pass_ninja_client.passes.get(
    'ptk_0x14', # passType
    '97694bd7-3493-4b39-b805-20e3e5e4c770' # serialNumber
)

Get Pass Template Details

pass_template_object = pass_ninja_client.pass_templates.find(
  'ptk_0x14', # pass template key
)
print(pass_template_object.pass_type_id)

Decrypt

Decrypts issued passes payload for a given pass template key

decrypted_pass_object = pass_ninja_client.passes.decrypt(
    'ptk_0x14', # passType
    '55166a9700250a8c51382dd16822b0c763136090b91099c16385f2961b7d9392d31b386cae133dca1b2faf10e93a1f8f26343ef56c4b35d5bf6cb8cd9ff45177e1ea070f0d4fe88887' # payload
)

Update

simple_pass_object = pass_ninja_client.passes.put(
    'ptk_0x14', # passType
    '97694bd7-3493-4b39-b805-20e3e5e4c770', # serialNumber
    {'discount': '100%', 'memberName': 'Ted'} # passData
)

Delete

deleted_pass_serial_number = pass_ninja_client.passes.delete(
    'ptk_0x14', # passType,
    '97694bd7-3493-4b39-b805-20e3e5e4c770' # serialNumber
)
print('Pass deleted. Serial_number: ', deleted_pass_serial_number)

Documentation

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

passninja-1.5.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

passninja-1.5.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file passninja-1.5.1.tar.gz.

File metadata

  • Download URL: passninja-1.5.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for passninja-1.5.1.tar.gz
Algorithm Hash digest
SHA256 b57a709bbc90000d84d0d4aa663dd06fc6f939e19f052d047ded6050a363ebc4
MD5 a28d83dd26f9aee291850bed60257640
BLAKE2b-256 1319c0cc12fe23f68482e9f3d28403cd561b6d226d5af8780a6d0115bb5faa1e

See more details on using hashes here.

File details

Details for the file passninja-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: passninja-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for passninja-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1dbd7a158da8fd271757203ecc9f18b911e3a0b2489b3c0a68b5292b27a21059
MD5 998f86c37aa21203fbae17123ee6cb92
BLAKE2b-256 830747c156e549667fbd296e184044d22f3acbabcc047b740db2808fabcc6638

See more details on using hashes here.

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