Skip to main content

A library to access Prestashop Web Service from Python.

Project description

Prestapyt

prestapyt is a library for Python to interact with the PrestaShop’s Web Service API.

Learn more about the PrestaShop Web Service from the [Official Prestashop Documentation].

prestapyt is a direct port of the PrestaShop PHP API Client, PSWebServiceLibrary.php

Similar to PSWebServiceLibrary.php, prestapyt is a thin wrapper around the PrestaShop Web Service: it takes care of making the call to your PrestaShop instance’s Web Service, supports the Web Service’s HTTP-based CRUD operations (handling any errors) and then returns the XML ready for you to work with in Python (as well as prestasac if you work with scala).

Installation

The easiest way to install prestapyt (needs setuptools):

easy_install prestapyt

Or, better, using pip:

pip install prestapyt

If you do not have setuptools, download prestapyt as a .tar.gz or .zip from [Prestapyt Source Archives], untar it and run:

python setup.py install

Usage

from prestapyt import PrestaShopWebServiceError, PrestaShopWebService

prestashop = PrestaShopWebService(’http://localhost:8080/api’, ‘BVWPFFYBT97WKM959D7AVVD0M4815Y1L’) # messages will be as xml # or prestashop = PrestaShopWebServiceDict(’http://localhost:8080/api’, ‘BVWPFFYBT97WKM959D7AVVD0M4815Y1L’) # messages will be as dict

# search / get all addresses prestashop.get(‘addresses’) # will return the same xml message than prestashop.search(‘addresses’) # but when using PrestaShopWebServiceDict prestashop.search(‘addresses’) will return a list of ids

# search with filters prestashop.search(‘addresses’, options={‘limit’: 10}) prestashop.search(‘addresses’, options={‘display’: ‘[firstname,lastname]’, ‘filter[id]’: ‘[1|5]’}) # reference for the options : http://doc.prestashop.com/display/PS14/Cheat+Sheet_+Concepts+Outlined+in+this+Tutorial

# get address 1 prestashop.get(‘addresses’, resource_id=1) # returns ElementTree (PrestaShopWebService) or dict (PrestaShopWebServiceDict) prestashop.get(‘addresses/1’)

# full url prestashop.get(’http://localhost:8080/api/addresses/1’)

# head print prestashop.head(‘addresses’)

# delete a resource prestashop.delete(‘addresses’, resource_ids=4)

# delete many resources prestashop.delete(‘addresses’, resource_ids=[5,6])

# add prestashop.add(‘addresses’, xml)

# edit prestashop.edit(‘addresses’, 5, xml)

# get a blank xml prestashop.get(‘addresses’, options={‘schema’: ‘blank’})

# add product image file_name = ‘sample.jpg’ fd = io.open(file_name, “rb”) content = fd.read() fd.close()

prestashop.add(‘/images/products/123’, files=[(‘image’, file_name, content)])

API Documentation

Documentation for the PrestaShop Web Service can be found on the PrestaShop wiki: [Using the REST webservice]

Credits:

Thanks to Prestashop SA for their PHP API Client PSWebServiceLibrary.php

Thanks to Alex Dean for his port of PSWebServiceLibrary.php to the Scala language, [prestasac] from which I also inspired my library.

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

prestapyt-0.6.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distributions

prestapyt-0.6.3-py2.7.egg (27.5 kB view details)

Uploaded Source

prestapyt-0.6.3-py2-none-any.whl (16.4 kB view details)

Uploaded Python 2

File details

Details for the file prestapyt-0.6.3.tar.gz.

File metadata

  • Download URL: prestapyt-0.6.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for prestapyt-0.6.3.tar.gz
Algorithm Hash digest
SHA256 76d712f8daaacfbfcca569c60844d7ca4709ab51f397a3468fdee62372d3eb4a
MD5 f8984c2e89cf81a347d971c1b020a231
BLAKE2b-256 af961a1e0dce3414ad58e9d064ad207b44b6f53b27b50d02d3aa7ee05b432e01

See more details on using hashes here.

File details

Details for the file prestapyt-0.6.3-py2.7.egg.

File metadata

File hashes

Hashes for prestapyt-0.6.3-py2.7.egg
Algorithm Hash digest
SHA256 5fa29ae648deaf66e6889a1c00d8e380b6cc88e0640392b825ac93f458ba1944
MD5 dd40de761ecf2c74452c80b4f2dddcd4
BLAKE2b-256 d9f1ac1917bf543579eaa7f2fa0cf2aaa7d0f933048bc975a52cf6dd0aa8b78e

See more details on using hashes here.

File details

Details for the file prestapyt-0.6.3-py2-none-any.whl.

File metadata

File hashes

Hashes for prestapyt-0.6.3-py2-none-any.whl
Algorithm Hash digest
SHA256 f04a46327205cea7b9f5c5be73fd2c781beabb74646908c96d94ece130807f69
MD5 5b5d1b9264501e042873a7dd1b283cfb
BLAKE2b-256 f8b2d4f7b2c683822f0f609000860264a87e8248b01355a86556b38067dfeaa8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page