GithubHelp home page GithubHelp logo

prexview / prexview-python Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 6.0 16 KB

Transform your data from XML or JSON to high quality, beautiful and readable documents in PDF, HTML, PNG or JPG.

Home Page: https://prexview.com

License: MIT License

Python 100.00%
xml json xml-parser json-parser xml-to-pdf xml-to-html xml-to-png json-to-pdf json-to-html json-to-png converter transform prexview

prexview-python's Introduction

PrexView

Status

A Python package to use PrexView, a fast, scalable and friendly service for programatic HTML, PDF, PNG or JPG generation using JSON or XML data.

See PrexView for more information about the service.

Installation

PyPI - Python Package Index

pip install prexview

Getting started

Get your API Key

You can get an API Key from PrexView

Set up your API Key

If you can setup enviroment variables

export PXV_API_KEY="YOUR_API_KEY"

If you can't setup environment variables, create the PrexView object with your API Key as argument

pxv = PrexView('YOUR_API_KEY')

Include the library

PyPI installation
from prexview import PrexView

Sending an XML

To send an XML string use pxv.sendXML(xml, options) method, this method will return a Response object on success or thrown an error.

Example
pxv = PrexView();

options = dict(template='supported_languages', output='pdf')

xml = '''<?xml version="1.0" encoding="UTF-8"?>
<languages>
  <lang code="en">English</lang>
  <lang code="es">Español</lang>
  <lang code="fr">Française</lang>
</languages>'''

file = 'test.pdf'

try:
  res = pxv.sendXML(xml, options)

  with open(file, 'wb') as f:
    f.write(res['file'])
    f.close()

  print 'File created:', file
except Exception as e:
  print e

Sending a JSON

To send a JSON string or dictionary object use pxv.sendJSON(json, options) method, this method will return a Response object on success or thrown an error.

Example
pxv = PrexView();

options = {'template': 'supported_languages', 'output': 'pdf'}

json = {
  'languages': [
    {'code': 'en', 'name': 'English'},
    {'code': 'es', 'name': 'Español'},
    {'code': 'fr', 'name': 'Française'}
  ]
}

file = 'test.pdf'

try:
  res = pxv.sendJSON(json, options)

  with open(file, 'wb') as f:
    f.write(res['file'])
    f.close()

  print 'File created:', file
except Exception as e:
  print e
Response object
Property Type Description
id string Transaction ID.
file binary Document created by the service.
responseTime int Response time from service.
rateLimit int Maximum number of calls to the service.
rateLimitReset int Seconds to reset the rate limit.
rateRemaining int Number of remaining call to the service.
Options
Name Type Required Description
template string Yes Template's name to be used to document creation, you can use dynamic values.
output string Yes Type of document that will be created by PrexView service, it must be html, pdf, png or jpg.
note string No Custom information to be added to the document's metadata, it's limit up to 500 characters and you can use dynamic values.
format string No Type of data used to the document creation, it must be xml or json, this should be inferred from library methods.
templateBackup string No Template's name to use to be used if the option template is not available in the service.
Dynamic values

In template or note options you can use JSON sintax to access data and have dynamic values, for instance having the following JSON data:

{
  "Data": {
    "customer": "123"
  }
}

Your template or note can use any data attribute or text node, for instance:

'invoice-customer-{{Data.customer}}'

Then we will translate that to the following:

'invoice-customer-123'

And finally the service will try to find the template or note invoice-customer-123 in order to transform the data and generate the document.

License

MIT © PrexView

prexview-python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

prexview-python's Issues

Cant install via pip

I want to try this out but unfortunately i cant install the python library via pip ill get this error msg

Could not find a version that satisfies the requirement prexview (from versions: ) No matching distribution found for prexview

Did you guys set it up correctly with PyPi ?

Snap data

{"Received Snap History":[{"From":"teamsnapchat","Media Type":"VIDEO","Created":"2022-11-11 17:41:20 UTC"},{"From":"teamsnapchat","Media Type":"VIDEO","Created":"2022-10-31 17:16:18 UTC"},{"From":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-27 15:47:20 UTC"},{"From":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-27 07:24:41 UTC"},{"From":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-24 19:54:31 UTC"},{"From":"deathbed2017","Media Type":"IMAGE","Created":"2022-10-24 19:45:09 UTC"},{"From":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-08 19:07:16 UTC"},{"From":"deathbed2017","Media Type":"IMAGE","Created":"2022-10-08 08:22:15 UTC"},{"From":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-28 17:52:56 UTC"},{"From":"skysmommy0115","Media Type":"IMAGE","Created":"2022-09-25 01:08:48 UTC"},{"From":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 21:32:55 UTC"},{"From":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 19:09:49 UTC"},{"From":"deathbed2017","Media Type":"VIDEO","Created":"2022-09-21 16:08:15 UTC"}],"Sent Snap History":[{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-24 19:51:52 UTC"},{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-24 19:51:20 UTC"},{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-24 19:48:17 UTC"},{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-10-08 07:14:11 UTC"},{"To":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 19:08:29 UTC"},{"To":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 19:06:35 UTC"},{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-09-21 15:59:38 UTC"},{"To":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 15:57:13 UTC"},{"To":"deathbed2017","Media Type":"IMAGE","Created":"2022-09-21 14:57:02 UTC"},{"To":"deathbed2017","Media Type":"VIDEO","Created":"2022-09-21 14:51:40 UTC"}]}

python 3.8

Hello,

It's compatible with python 3.8?

I tried, but the error occurs:

400 Client Error: Bad Request for url: https://api.prexview.com/v1/transform

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.