Official Pincho client library for Python
Project description
Pincho Python Library
Official Python client for Pincho push notifications.
Installation
pip install pincho-sdk
Quick Start
from pincho import Pincho
# Auto-load token from PINCHO_TOKEN env var
with Pincho() as client:
client.send('Deploy Complete', 'Version 1.2.3 deployed')
# Or provide token explicitly
with Pincho(token='YOUR_TOKEN') as client:
client.send('Alert', 'Server CPU at 95%')
Features
# Full parameters
client.send(
title='Deploy Complete',
message='Version 1.2.3 deployed',
type='deployment',
tags=['production', 'backend'],
image_url='https://example.com/success.png',
action_url='https://example.com/deploy/123'
)
# AI-powered notifications (NotifAI)
response = client.notifai('deployment finished, v2.1.3 is live')
print(response.notification) # AI-generated title, message, tags
# Encrypted messages
client.send(
title='Security Alert',
message='Sensitive data',
type='security',
encryption_password='your_password'
)
# Async support
from pincho import AsyncPincho
async with AsyncPincho() as client:
await client.send('Test', 'Message')
Configuration
# Environment variables (recommended)
# PINCHO_TOKEN - API token (required if not passed to constructor)
# PINCHO_TIMEOUT - Request timeout in seconds (default: 30)
# PINCHO_MAX_RETRIES - Retry attempts (default: 3)
# Or explicit configuration
client = Pincho(
token='abc12345',
timeout=60.0,
max_retries=5
)
Error Handling
from pincho import (
Pincho,
AuthenticationError,
ValidationError,
RateLimitError
)
try:
with Pincho() as client:
client.send('Title', 'Message')
except AuthenticationError:
print("Invalid token")
except ValidationError:
print("Invalid parameters")
except RateLimitError:
print("Rate limited - auto-retry handled this")
Automatic retry with exponential backoff for network errors, 5xx, and 429 (rate limit).
Smart Rate Limiting
The library automatically handles rate limits with Retry-After header support:
with Pincho() as client:
client.send('Alert', 'Message')
# Check rate limit status after any request
if client.last_rate_limit:
print(f"Remaining: {client.last_rate_limit.remaining}/{client.last_rate_limit.limit}")
print(f"Resets at: {client.last_rate_limit.reset}")
See Advanced Documentation for detailed rate limit monitoring patterns.
Links
- Get Token: App → Settings → Help → copy token
- Documentation: https://pincho.dev/help
- Repository: https://gitlab.com/pincho/pincho-python
- PyPI: https://pypi.org/project/pincho/
License
MIT
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 pincho_sdk-1.0.0a6.tar.gz.
File metadata
- Download URL: pincho_sdk-1.0.0a6.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f089a8d273ff1fa1dc1a36fe40258cf223ce47acb85b3aebf0b7e58cfb629f9
|
|
| MD5 |
5acfb7f051c997824ede3e1a91e6502e
|
|
| BLAKE2b-256 |
f16a2c977768e38cb217d09f1a1e520b6d7f82bc166319ed9d2280850045601c
|
File details
Details for the file pincho_sdk-1.0.0a6-py3-none-any.whl.
File metadata
- Download URL: pincho_sdk-1.0.0a6-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82f6451bc00a78b7441435a06f9ef81e100e9a8da180684576c8a83acf3ab6ca
|
|
| MD5 |
b5d3202edc2478b2ee43bb2b2952edb2
|
|
| BLAKE2b-256 |
d02c9fb1c77e6979fed5b7c889d075c7478c26d997e2210ff184df6d77f54133
|