- Loris Modena
- Tutorial Prestashop
In information technology, a Web Service for the W2C standard is software designed for interoperability between different computers on the same network. PrestaShop has its own Web Service that can be useful for exchanging data between PrestaShop and another software that can be a management system, a web service for synchronization with your Ebay or Amazon store, etc ...
The first operation to be performed in order to use the WebService is to enable it, to do this we will have to go to: Advanced parameters -> Webservice
Click on the + to create a new web service
- We click on "Generate!" to create a new key to access the webservice
- We insert a description for the key we are creating, to remind us what the web service is for, for example: "GLS synchronization" if the web service is used to connect to the courier.
- Status, allows you to activate or disable the key at any time, let's set it to YES to activate access.
- Permissions, here we can decide which permissions to enable methods are GET, PUT, POST, DELETE and HEAD. In the example we select all the GET permissions.
Once this is done, click on "SAVE".
We just have to activate the PrestaShop WebService now by activating the item "Activate PrestaShop web service", in most cases our server has the CGI mode for PHP, so we also activate the item "Enable CGI mode for PHP" and click on SAVE
Now we can query the PrestaShop web service by retrieving the URL address as follows: http: //firstname.lastname@example.org/api/ or http: //domainname.ext/api/? Ws_key = key
Example: https: //MNXB51PKR6LGRQWS7CNBSUI3JNBVNYSS@www.demomodule.com/api/ or https://www.demomodule.com/api/?ws_key=MNXB51PKR6LGRQWS7CNBSUI3JNBVNYSS
Note: we can also indicate the method for example & ps_method = GET or the format for example for JSON we will add to the URL & output_format = JSON .
If our domain is www.demomodule.com and our key is MNXB51PKR6LGRQWS7CNBSUI3JNBVNYSS If we do not enter the key in the first call, it will be requested by our browser, in this case it will be sufficient to indicate the key in question as the User Name, without indicating any password.
The call will return the available methods:
We thus ran various queries by receiving the response in XML format from the WebService, for example we can receive the list of all orders by calling the following url: https://www.demomodule.com/api/orders.
Note: You will not need to pass the key again for subsequent queries.
By calling URL https://www.demomodule.com/api/orders/1 we will have the details of the order with ID 1.
If we have enabled the DELETE method we can also delete data for example: https://www.demomodule.com/api/customers/112/?ws_key=MNXB51PKR6LGRQWS7CNBSUI3JNBVNYSS&ps_method=DELETE
We are going to delete the customer with ID number 112.
Author: Loris Modena