Client for interacting with Pinapple
Project description
🍍 PinappleClient 🍍
A Python client for interacting with the Pinapple encryption API.
🚀 Features
- Authentication 🔐 - Token-based API authentication with automatic refresh
- Flexible Encryption ⚡ - Support for strict and loose encryption modes
- Fallback Strategy 🔄 - Automatic fallback from strict to loose encryption
- Smart Token Management ⏰ - Configurable token refresh with expiration handling
📦 Installation
pip install PinappleClient
🔧 Quick Start
from pinapple_client import PinappleClient
# Initialize client with automatic token refresh
client = PinappleClient(
user="your_username",
password="your_password",
api_url="https://api.pinapple.com",
refresh_buffer_minutes=5 # Refresh token 5 minutes before expiration
)
# Encrypt a single PIN
encrypted_pin = client.encrypt_pin_strict("123456")
print(f"Encrypted: {encrypted_pin}")
# Decrypt data
decrypted_pin = client.decrypt_pin(encrypted_data)
print(f"Decrypted: {decrypted_pin}")
📊 DataFrame Operations
encrypt_dataframe(df, column, strict=True, strict_then_loose=False) -> DataFrame
Encrypts an entire column in a pandas DataFrame.
import pandas as pd
df = pd.DataFrame({
'id': [1, 2, 3],
'pin': ['123456', '789012', '345678']
})
# Encrypt the 'pin' column
encrypted_df = client.encrypt_dataframe(df, 'pin', strict=True)
# Use fallback strategy
encrypted_df = client.encrypt_dataframe(df, 'pin', strict_then_loose=True)
Parameters:
df: Input DataFramecolumn: Column name to encryptstrict: Use strict encryption (default: True)strict_then_loose: Enable fallback strategy (default: False)
🔒 Authentication & Token Management
The client automatically handles token management with intelligent refresh:
Automatic Token Refresh
- Requests a bearer token on first API call
- Caches the token for subsequent requests
- Automatically refreshes tokens before expiration based on configurable buffer time
- Handles long-running operations without token expiry issues
Token Configuration
# Refresh token 10 minutes before it expires
client = PinappleClient(..., refresh_buffer_minutes=10)
# Check token status
expiration = client.get_token_expiration()
should_refresh = client.should_refresh_token()
Token Utilities
get_token_expiration()- Returns token expiration as datetimeshould_refresh_token()- Checks if token needs refresh based on buffer- Automatic refresh during long DataFrame operations
Perfect for long-running encryption jobs - no manual token management required!
📄 License
This project is licensed under the GPL-3.0 License.
🔗 Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pinappleclient-1.2.0.tar.gz.
File metadata
- Download URL: pinappleclient-1.2.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54576b2386b9047b5da2c68a28437aa313626f3cc1933cb6737bd6217411b22a
|
|
| MD5 |
8d9b20bb78e93b0ab130efcaad68305f
|
|
| BLAKE2b-256 |
06566a142e9192adb04b2e494357a94200bcce55d42c37f4af213de038afd0d1
|
File details
Details for the file pinappleclient-1.2.0-py3-none-any.whl.
File metadata
- Download URL: pinappleclient-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b6e83d91a89be5cd13e6419bfc742f03820149ee9d3827c27fa835e65a3c575
|
|
| MD5 |
e83bd73e5844e722d30109f08e2bcc59
|
|
| BLAKE2b-256 |
b93183c076fad09e71e4e3ae8b5ab6233b7e11dcd4ab65bee0514fa65ac90e82
|