Skip to main content

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

In 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@master

Usage

Message as xml

from prestapyt import PrestaShopWebService
prestashop = PrestaShopWebService('http://localhost:8080/api', WEBSERVICE_KEY)

Message as dictionary

from prestapyt import PrestaShopWebServiceDict
prestashop = PrestaShopWebServiceDict('http://localhost:8080/api', WEBSERVICE_KEY)

Search

Get all addresses

prestashop.get('addresses') # will return the same xml message than
prestashop.search('addresses')

Note: 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]'})

For additional info check reference for the options.

Get single address

prestashop.get('addresses', resource_id=1) or prestashop.get('addresses/1')

returns ElementTree (PrestaShopWebService) or dict (PrestaShopWebServiceDict).

You can use the full api URL

prestashop.get('http://localhost:8080/api/addresses/1')

Head request

prestashop.head('addresses')

Manipulate records

Delete

prestashop.delete('addresses', resource_ids=4)

Delete many records at once

prestashop.delete('addresses', resource_ids=[5,6])

Add record

prestashop.add('addresses', xml)

Edit record

prestashop.edit('addresses', xml)

Get model blank xml schema

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.

Copyright and License

prestapyt is copyright (c) 2012 Guewen Baconnier

prestapyt 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, see GNU licenses.

Release files for prestapyt 0.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prestapyt 0.11.1
File Size Uploaded
prestapyt-0.11.1.tar.gz 28.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prestapyt 0.11.1
File Interpreter ABI Platform
prestapyt-0.11.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 54.6 kB

Release files / prestapyt-0.11.1.tar.gz

Download URL prestapyt-0.11.1.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bebd1980f25822ddeeb908f3452755d9213e902c8dbd8e8195fe08eb8eca1341
BLAKE2b-256 checksum
How to use checksums
2bd9a65da349392fa3e0ab25b29cf61376c725b5430508cc13005b6366f7d174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / prestapyt-0.11.1-py2.py3-none-any.whl

Download URL prestapyt-0.11.1-py2.py3-none-any.whl
Size 26.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1dd49d9dccb8c27a35e760c9813e48704b0a659e80cf501f655be11c171e612f
BLAKE2b-256 checksum
How to use checksums
fd1b2ff05cda7c6f2e3fbeba71254f8c7187192b5d04c56f540661daeee463d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.11.1 This release

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.2

2 release files

0.9.0

3 release files

0.8.0

3 release files

0.7.0

3 release files

0.6.3

3 release files

0.6.2

3 release files

0.6.1

3 release files

0.6.0

3 release files

0.5.3

3 release files

0.5.2

2 release files

0.5.1

3 release files

0.5.0

2 release files

0.4.0

3 release files

0.3.1

3 release files

0.3.0

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.1

3 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page