GithubHelp home page GithubHelp logo

simsys / lxpapi Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 65 KB

Library and Command Line Interface for the LxpApi (www.letterxpress.de)

License: GNU Lesser General Public License v3.0

Python 99.05% Shell 0.95%
python python-3 rest-api online-printing command-line-tool

lxpapi's Introduction

LxpApi

Library and Command-Line Interface for the LxpApi (www.letterxpress.de)

The package consists of two building blocks:

  • Python library LxpApi to integrate the interface into Python applications.
  • Command line tool lxpservice, which is explained here.

Installing LxpApi

As usual, LxpApi is installed with pip (or pip3). This will install both the library and the command line tool.

$pip install lxpservice

Using LxpApi

First import the LxpAPi library and pprint for nice view on complex python types.

>>> from LxpApi import LxpApi
>>> from pprint import pprint

Create an instance of LxpApi with the credentials

>>> url = "https://sandbox.letterxpress.de/v1/"
>>> user = <User-Name>
>>> api_key = <Api-Key>
>>> lxp_api = LxpApi(url, user, api_key)

Now we can work with the API and execute various commands. The library always returns an answer from which it can be seen if the function could be executed successfully.

Let's first look at the current credit balance.

>>> response = lxp_api.get_balance()
>>> pprint(response)
{'auth': {'id': '46', 'status': 'active', 'user': <User-Name>},
 'balance': {'currency': 'EUR', 'value': '91.59'},
 'message': 'OK',
 'status': 200}

Now we upload a PDF file to the server

>>> response=lxp_api.set_job('one-page.pdf')
>>> pprint(response)
{'auth': {'id': '46', 'status': 'active', 'user': <User-Name>},
 'letter': {'job_id': '3422',
            'price': 0.74,
            'specification': {'color': 1,
                              'mode': 'simplex',
                              'page': 1,
                              'ship': 'national'},
            'status': 'queue'},
 'message': 'OK',
 'status': 200}

In response, we receive some information such as the price or other attributes of the order. These attributes can be influenced during upload. How todo this and other information can be found in the library documentation. Alternatively they can be retrieved with help(LxpApi). All available methods and possible parameters are described here.

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.