Skip to main content

An API wrapper for Stannp, a service for sending snail mail via a web api, such as postcards and letters.

Project description

A Python API wrapper for Stannp by AndyPi

What is Stannp?

Stannp allows you to send snail mail via a web api. It includes postcards and letters. See stannp.com for more details.

Installation

pip install stannp

Example Usage

Initialisation

import the module and create an instance with your Stannp API Key

from stannp import StannpClient
STANNP_API_KEY="XXXXXXXXXXXX"
stannpinstance=StannpClient(STANNP_API_KEY)

Test send a postcard and return the JSON repsonse

# set recipient using a python dictionary
recipient={'title': 'Mr', 'firstname':'Andy', 'lastname':'Pi', 'address1': 'My House', 'address2': 'My Town', 'city':My City', 'postcode': 'Postcode', 'country':'GB'}
# Set the message text
message="Hi Friend,\n\n This is a sample postcard using AndyPi's stannp-api wrapper for python"
# Creates the postcard (where test.jpg is the filename of the front of the card)
card=stannpinstance.send_postcard(size="A6", test=True, recipient=recipient, front="test.jpg", back=None, message=message, signature=None)
# Prints the JSON repsonse from the stannp server, including the URL of a PDF preview
print card

Test send a letter and return the PDF preview URL from the repsonse

# set recipient using a python dictionary
recipient={'title': 'Mr', 'firstname':'Andy', 'lastname':'Pi', 'address1': 'My House', 'address2': 'My Town', 'city':My City', 'postcode': 'Postcode', 'country':'GB'}
# Set the message text to be a PDF named test.pdf (note the first page will have the recipients address)
letter=stannpinstance.send_letter(test=True, template=None, recipient=recipient, background=None, pages="test.pdf", pdforhtml="pdf")
# print the URL of the preview PDF
print letter['data']['pdf']

Other

Please see the comments / doctrings in stannp.py to understand how to use all the functions.

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

stannp-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file stannp-1.0.0.tar.gz.

File metadata

  • Download URL: stannp-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for stannp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4cdedd0572b40a2d83419a32c0ffced4b94e9fc6990a3caaed0f5105813ac218
MD5 1fab61a77666f9e416d3aa8f0eba04cc
BLAKE2b-256 44c631fab2c941950db9eaebb54377f6ab88b9f623c6a9fb6099c661387e0dbd

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