Prestashop is a library for Python to interact with the PrestaShop's Web Service API.
Project description
Prestashop
Prestashop is a library for Python to interact with the PrestaShop's Web Service API.
Learn more about the Prestashop Web Service from the Official Documentation
Installation
using pip :
pip install prestashop
the git repo:
git clone https://github.com/AiSyS-Next/prestashop
cd prestashop
pip install .
Usage
init api
for json data format
from prestashop import Prestashop, Format
api = Prestashop(
url = "https://myprestashop.com",
api_key="4MV3E41MFR7E3N9VNJE2W5EHS83E2EMI",
default_lang=1,
debug=True,
data_format=Format.JSON,
)
for xml data format
from prestashop import Prestashop, Format
api = Prestashop(
url = "https://myprestashop.com",
api_key="4MV3E41MFR7E3N9VNJE2W5EHS83E2EMI",
default_lang=1,
debug=True,
data_format=Format.XML,
)
Test API
test if you webservice run
api.ping()
Create Record
data = {
'tax':{
'rate' : 3.000,
'active': '1',
'name' : {
'language' : {
'attrs' : {'id' : '1'},
'value' : '3% tax'
}
}
}
}
rec = api.create('taxes',data)
Add product image
file_name = 'sample.jpg'
api.create_binary('images/products/30',file=file_name , _type='image')
Update record
update_data = {
'tax':{
'id' : str(rec['id']),
'rate' : 3.000,
'active': '1',
'name' : {
'language' : {
'attrs' : {'id' : '1'},
'value' : '3% tax'
}
}
}
}
update_rec = api.write('taxes',update_data)
Remove record
api.unlink('taxes',str(rec['id']))
remove many records at once
api.unlink('taxes',[2,4,5])
Read
import pprint
result = api.read('taxes','2',display='[id,name]')
pprint(result)
Search
# search the first 3 taxes with 5 in the name
import pprint
recs = api.search('taxes',_filter='[name]=%[5]%',limit='3')
for rec in recs:
pprint(rec)
# search with id = 3 or id = 5
recs = api.search('taxes' ,_filter='[id]=[3 | 5]')
Copyright and License
prestashop is copyright (c) 2023 Aymen Jemi (AISYSNEXT)
prestashop is free software: you can redistribute it and/or modify it under the terms of the GPLv3 General Public License as published by the Free Software Foundation, version 3 of the License .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prestashop-0.1.8.tar.gz.
File metadata
- Download URL: prestashop-0.1.8.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae165d2a746b319d7ac8c76a2716b3439b36716f47d843d193c998a2fc4407a7
|
|
| MD5 |
2678f3189156ffa52f7a44ec52af8981
|
|
| BLAKE2b-256 |
fbec2b5e4e7290935a8d8938dcd3e5a918184868a65b19304148638ebccce71a
|
File details
Details for the file prestashop-0.1.8-py3-none-any.whl.
File metadata
- Download URL: prestashop-0.1.8-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a21d4411f41dcfc969c6e3c5c9e3b220916d3cb0fa7d41c4db475e6be0458503
|
|
| MD5 |
9b14885126f5369bb8fb1121fe5166f2
|
|
| BLAKE2b-256 |
90c5c5a33baa24a401a65fe76a7b0eafd7df15fb0086ec85aeb406f0c4ce2939
|