prestashop


Nameprestashop JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/AISYSNEXT-Ltd/prestashop
SummaryPrestashop is a library for Python to interact with the PrestaShop's Web Service API.
upload_time2024-02-26 08:37:29
maintainer
docs_urlNone
authorAymen Jemi <jemiaymen@gmail.com> (AISYSNEXT)
requires_python
licenseGNU GPL-3
keywords prestashop e-com e-commerce prestashop api api webservice
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://devdocs.prestashop-project.org/1.7/webservice/)

## Installation

using pip :

`pip install prestashop`

the git repo:

```bash
git clone https://github.com/AiSyS-Next/prestashop 
cd prestashop
pip install . 
```

## Usage

### init api

for json data format

```python
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

```python
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

```python
api.ping()
```

### Create Record

```python
data = {
        'tax':{
            'rate' : 3.000,
            'active': '1',
            'name' : {
                'language' : {
                    'attrs' : {'id' : '1'},
                    'value' : '3% tax'
                }
            }
        }
    }

rec = api.create('taxes',data)
```
#### Add product image

```python
file_name = 'sample.jpg'

api.create_binary('images/products/30',file=file_name , _type='image')
```



### Update record

```python
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

```python
api.unlink('taxes',str(rec['id']))
```

remove many records at once

```python
api.unlink('taxes',[2,4,5])
```

### Read

```python
import pprint
result = api.read('taxes','2',display='[id,name]')

pprint(result)
```

### Search

```python
 # 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 .

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AISYSNEXT-Ltd/prestashop",
    "name": "prestashop",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "prestashop,e-com,e-commerce,prestashop api,api,webservice",
    "author": "Aymen Jemi <jemiaymen@gmail.com> (AISYSNEXT)",
    "author_email": "jemiaymen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fb/ec/2b5e4e7290935a8d8938dcd3e5a918184868a65b19304148638ebccce71a/prestashop-0.1.8.tar.gz",
    "platform": null,
    "description": "# Prestashop\nPrestashop is a library for Python to interact with the PrestaShop's Web Service API.\n\nLearn more about the Prestashop Web Service from the [Official Documentation](https://devdocs.prestashop-project.org/1.7/webservice/)\n\n## Installation\n\nusing pip :\n\n`pip install prestashop`\n\nthe git repo:\n\n```bash\ngit clone https://github.com/AiSyS-Next/prestashop \ncd prestashop\npip install . \n```\n\n## Usage\n\n### init api\n\nfor json data format\n\n```python\nfrom prestashop import Prestashop, Format\n\napi = Prestashop(\n    url = \"https://myprestashop.com\",\n    api_key=\"4MV3E41MFR7E3N9VNJE2W5EHS83E2EMI\",\n    default_lang=1,\n    debug=True,\n    data_format=Format.JSON,\n)\n```\n\nfor xml data format\n\n```python\nfrom prestashop import Prestashop, Format\n\napi = Prestashop(\n    url = \"https://myprestashop.com\",\n    api_key=\"4MV3E41MFR7E3N9VNJE2W5EHS83E2EMI\",\n    default_lang=1,\n    debug=True,\n    data_format=Format.XML,\n)\n```\n\n### Test API\n\ntest if you webservice run\n\n```python\napi.ping()\n```\n\n### Create Record\n\n```python\ndata = {\n        'tax':{\n            'rate' : 3.000,\n            'active': '1',\n            'name' : {\n                'language' : {\n                    'attrs' : {'id' : '1'},\n                    'value' : '3% tax'\n                }\n            }\n        }\n    }\n\nrec = api.create('taxes',data)\n```\n#### Add product image\n\n```python\nfile_name = 'sample.jpg'\n\napi.create_binary('images/products/30',file=file_name , _type='image')\n```\n\n\n\n### Update record\n\n```python\nupdate_data = {\n        'tax':{\n            'id' : str(rec['id']),\n            'rate' : 3.000,\n            'active': '1',\n            'name' : {\n                'language' : {\n                    'attrs' : {'id' : '1'},\n                    'value' : '3% tax'\n                }\n            }\n        }\n    }\n\nupdate_rec = api.write('taxes',update_data)\n```\n### Remove record\n\n```python\napi.unlink('taxes',str(rec['id']))\n```\n\nremove many records at once\n\n```python\napi.unlink('taxes',[2,4,5])\n```\n\n### Read\n\n```python\nimport pprint\nresult = api.read('taxes','2',display='[id,name]')\n\npprint(result)\n```\n\n### Search\n\n```python\n # search the first 3 taxes with 5 in the name \nimport pprint\nrecs = api.search('taxes',_filter='[name]=%[5]%',limit='3')\n\nfor rec in recs:\n    pprint(rec)\n\n\n# search with id = 3 or id = 5\n\nrecs = api.search('taxes' ,_filter='[id]=[3 | 5]')\n```\n\n\n## Copyright and License\n\nprestashop is copyright (c) 2023 Aymen Jemi (AISYSNEXT)\n\nprestashop is free software: you can redistribute it and/or modify\nit under the terms of the GPLv3 General Public License as\npublished by the Free Software Foundation, version 3 of\nthe License .\n",
    "bugtrack_url": null,
    "license": "GNU GPL-3",
    "summary": "Prestashop is a library for Python to interact with the PrestaShop's Web Service API.",
    "version": "0.1.8",
    "project_urls": {
        "Homepage": "https://github.com/AISYSNEXT-Ltd/prestashop"
    },
    "split_keywords": [
        "prestashop",
        "e-com",
        "e-commerce",
        "prestashop api",
        "api",
        "webservice"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90c5c5a33baa24a401a65fe76a7b0eafd7df15fb0086ec85aeb406f0c4ce2939",
                "md5": "9b14885126f5369bb8fb1121fe5166f2",
                "sha256": "a21d4411f41dcfc969c6e3c5c9e3b220916d3cb0fa7d41c4db475e6be0458503"
            },
            "downloads": -1,
            "filename": "prestashop-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9b14885126f5369bb8fb1121fe5166f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21146,
            "upload_time": "2024-02-26T08:37:27",
            "upload_time_iso_8601": "2024-02-26T08:37:27.505731Z",
            "url": "https://files.pythonhosted.org/packages/90/c5/c5a33baa24a401a65fe76a7b0eafd7df15fb0086ec85aeb406f0c4ce2939/prestashop-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fbec2b5e4e7290935a8d8938dcd3e5a918184868a65b19304148638ebccce71a",
                "md5": "2678f3189156ffa52f7a44ec52af8981",
                "sha256": "ae165d2a746b319d7ac8c76a2716b3439b36716f47d843d193c998a2fc4407a7"
            },
            "downloads": -1,
            "filename": "prestashop-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "2678f3189156ffa52f7a44ec52af8981",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20756,
            "upload_time": "2024-02-26T08:37:29",
            "upload_time_iso_8601": "2024-02-26T08:37:29.112602Z",
            "url": "https://files.pythonhosted.org/packages/fb/ec/2b5e4e7290935a8d8938dcd3e5a918184868a65b19304148638ebccce71a/prestashop-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 08:37:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AISYSNEXT-Ltd",
    "github_project": "prestashop",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "prestashop"
}
        
Elapsed time: 0.20041s