PyPostal是一个通过API(PixelLetter)发送真实(纸质)信件的接口
pyPostal的Python项目详细描述
pyposal是一个通过api发送真实(纸质)信件的接口。
有几家供应商提供印刷、信封填充和邮寄服务,但目前只有 https://www.pixelletter.de/向中小企业提供此类服务,而无合同纠纷等。
此接口仅支持将地址放在pdf中DIN 5008地址位置的pdf邮寄。
你可以在Python PAckage Index (PyPI)下载。
高水平使用
使用非常简单:在启动python之前,只需在环境中设置凭据:
export PYPOSTAL_PIXELLETTER_CRED='your@email.com:PASSWORD'
然后使用打开的pdf文件或pdf数据流调用pypostal.send_post_pixelletter(),发送收件人的国家/地区代码:
>>> import pypostal >>> pypostal.send_post_pixelletter( [open('/Users/md/Desktop/Testbrief.pdf').read()], 'DE')
如果您喜欢硬编码凭据,可以通过函数调用而不是通过环境来提供它们:
>>> pypostal.send_post_pixelletter([open('Testbrief.pdf')], 'DE', username='your@email.com', password='PASSWORD')
像素字母接口
PixelLetter提供一个Bunch of Documentation和一个PHP Library。不幸的是,没有http-api规范,文档似乎也有些不完整和过时。而且,pixelletter似乎不使用预构建的xml处理和解析管道,而是构建一个arround print语句。这个图书馆是用反复试验和逆向工程的方法建立的。
示例用法
PixelLetter接口很简单:
# Log in >>> from pypostal import Pixelletter >>> pix = Pixelletter('your_email', 'your_password', test_mode=True) # Show how many Cents Pixelletter owes you. >>> print pix.get_account_info()['customer_credit'] 1995 # Send two PDFs from your Desktop as en Letter >>> print pix.sendPost([open('/Users/md/Desktop/Testbrief.pdf'), open('/Users/md/Desktop/Thesis.pdf')]) # Send one PDF printet in color and in CO2 neutral fashion. >>> print pix.sendPost([open('/Users/md/Desktop/Testbrief.pdf').read()], guid='0815-4711', service=['green', 'color'])
您可以提供一个guid(pixelletter文档中的“事务标识符”),这可能支持一个跟踪和跟踪接口,但我还没有看到任何关于这个的文档。像https://www.pixelletter.de/de/auftraege.php这样的东西作为Atom Feed的垂直将是很好的。
python库目前支持以下服务:
- 绿色(默认情况下,使用service=[]禁用)
- 爱因斯坦(参见DHL / Deutsche Post AG关于差异)
- 在wurf中的阈值
- 本征血红素
- 本征血凝素
- rueckschein
- 颜色
PixelLetter API似乎也支持“NachNahme”、“Postident Comfort”和“Ueberweisungsvordruck”,但它们没有文档记录,目前不受此库支持。
sipgate.de传真接口
sipgate.de提供了一个新的带有some documentation的rest api。Pypposal提供通过传真发送PDF的功能。
示例用法
一个漂亮干净的界面:
# Log in >>> from pypostal.sipgate import Sipgate >>> sip = Sipgate('your_email', 'your_password') # Send a PDF via Fax >>> sip.sendFax([open('/Users/md/Desktop/Testbrief.pdf')], 'sender_number', ['dest_number'])
计划的其他接口
我们希望支持
- PixelLetter传真接口
- pawisda l-vin post/pinbriefportal soap接口
链接
- WWW::Pixelletter(perl模块)用于像素字母
- PHP Library用于像素字母
- Pixelletter Documentation
- pyJasper和iReport是生成pdf的一种不错的方法。