Package: prestapyt
Prestapytprestapyt is a library for Python to interact with the PrestaShop's Web Service API.Learn more about the PrestaShop Web Service from theOfficial Prestashop Documentation.prestapyt is a direct port of the PrestaShop PHP API Client, PSWebServiceLibrary.phpSimilar 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).InstallationThe easiest way to install prestapyt (needs setuptools):easy_install prestapytOr, better, using pip:pip install prestapytIf you do not have setuptools, download prestapyt as a .tar.gz or .zip fromPrestapyt Source Archives, untar it and run:python setup.py installIn order to always be uptodate, the best way is to use pip from this repo with the following command :pip install --ignore-installed git+https://github.com/prestapyt/prestapyt.git@masterUsageMessage as xmlfromprestapytimportPrestaShopWebServiceprestashop=PrestaShopWebService('http://localhost:8080/api',WEBSERVICE_KEY)Message as dictionaryfromprestapytimportPrestaShopWebServiceDictprestashop=PrestaShopWebServiceDict('http://localhost:8080/api',WEBSERVICE_KEY)SearchGet all addressesprestashop.get('addresses')# will return the same xml message thanprestashop.search('addresses')Note: when using PrestaShopWebServiceDictprestashop.search('addresses')will return a list of ids.Search with filtersprestashop.search('addresses',options={'limit':10})prestashop.search('addresses',options={'display':'[firstname,lastname]','filter[id]':'[1|5]'})For additional infocheck reference for the options.Get single addressprestashop.get('addresses',resource_id=1)orprestashop.get('addresses/1')returns ElementTree (PrestaShopWebService) or dict (PrestaShopWebServiceDict).You can use the full api URLprestashop.get('http://localhost:8080/api/addresses/1')Head requestprestashop.head('addresses')Manipulate recordsDeleteprestashop.delete('addresses',resource_ids=4)Delete many records at onceprestashop.delete('addresses',resource_ids=[5,6])Add recordprestashop.add('addresses',xml)Edit recordprestashop.edit('addresses',xml)Get model blank xml schemaprestashop.get('addresses',options={'schema':'blank'})Add product imagefile_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 DocumentationDocumentation for the PrestaShop Web Service can be found on the
PrestaShop wiki:Using the REST webserviceCredits:Thanks to Prestashop SA for their PHP API Client PSWebServiceLibrary.phpThanks to Alex Dean for his port of PSWebServiceLibrary.php
to the Scala language,prestasacfrom which I also inspired my library.Copyright and Licenseprestapyt is copyright (c) 2012 Guewen Baconnierprestapyt is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.prestapyt is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public
License along with prestapyt. If not, seeGNU licenses.