Prestashop has an internal webservice which allows accessing a store from a remote application. Since the service is based on REST technology, this allows the remote applications to be cross-platform and use CRUD queries.
To start using the webservice you need to enable it first. To switch on the service go to Advanced Parameters -> Webservice:
Enable Active mode CGI for PHP if your server uses PHP not as an Apache module.
Next you need to create an Access Key, which you will have to specify when connecting the webservice to Prestashop. Each key gives access only to certain resources of the store. To generate a key go to Advanced Parameters -> Webservice -> Add New.
You will need to specify the key code, its description, status, configure access to the necessary system resources. You can also specify which CRUD requests will be available for each Prestashop resource (View, Mоdufy, Add, Delete, Fast view ). There is also an option to configure a multishop-association:
After querying this URL Prestashop will return an XML file with the list of all resources and all permitted CRUD operations for that resource for the specified Access Key.
Partner With UsLet's discuss how to grow your business. Get a Free Quote.
An example of the response:
An example of the response:
The requests will work only if you allow the method GET for the resource Customer.
As shown in the table below, CRUD requests correspond to the type of an HTTP-request:
Comparison table of CRUD-requests and types of SQL queries.
|HTTP / REST||CRUD||SQL|
To delete a resource entity use the following request pattern.
Fill out the XML with necessary data and send it back using the query.
All requests have a similar structure for each Prestashop resource. The main thing is that there should be access allowed to that resource and to CRUD operations for the key being used.
There is a ready-to-use PHP library written by Prestashop developers to work with the webservice. The library is available on Github. To use this library you should install cURL on the server with a remote application.
You can find examples of usage here.
BelVG PrestaShop Store
Take your online store to the next level with PrestaShop modules by BelVGClick to visit the store
Looking for a quality PrestaShop solution? Find a suitable one at BelVG store.
hi guys, hello from portugal :)
i’m newer at prestashop, i’m trying to use web services from prestashop to comunicate with other api (PHC), but for now i’m trying with standard prestashop web service (backoffice) and i’m testing with chrome extension (POSTMAN)…and the results are:
GET and DELETE are ok…
But POST and PUT :( not…
I have read and read a lot of information (google) but until now i’m not able to find something that works for me.
Some help please!!!!
Hi 2 all and thanks for the post. I’m trying to developing a new model to sync both prestashop sites using webservices but first step to do that is enable automatically webservices when my custom module is installed.
Is there a way to do that?
@betty GET param should be “output_format” or “io_format”.
Also, you can specify format in requests headers https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/classes/webservice/WebserviceRequest.php#L228
how to get the jsonformat data from webservice insted of xml format
?outputformat=json in url not working show a blank page
@vipul please, share your code and result XML (you can use pastebin.com to upload your code)
Hi, this is a nice blog i have completed my application with prestashop restfull service i just need to place an order. with shiping and discount but it is giving error each time i place an order can u help me to place an order with rest full service.
I have a doubt. Is it possible to send JSON request in Prestashop webservice?
Can you please give us sample xml request to be send with the required parameters especially for creation and updation of products and orders?
Thank you so much for the blog. It was more than useful for me.
Short as well as sweet one.
Great post, more easy than the Prestashop’s docs.
Did you know how to erase products images? I’m trying it but I don’t have permission to delete it
I’m working in a little script to remove duplicate images comparing all images of a product.
this is helpful and clear.
1. i am just starting with prestashop and was wondering whether prestashop allows additional resources to be registered with the rest engine, so you can use it to access other resources than the ones in the default list. ( and of course in order to do so, what additional coding lies ahead )
I have a prestashop running as a catalog, my problem is that I want to update the products stock via webservice. The webservice is provided by the supplier but I don’t know how to connect the WSDL from the supplier to my prestashop.
Can you help me?
I’m not getting the field in localhost/prestashop/api/customers/?schema=blank where can i find this?
please can any one help on this?
how can i display lastname field under customer resource in prestashop
Great article, I however get an error when I try to view a specific order. Below is the error I get. When I turn debugging on it works fine. As soon as I turn it off the error returns. Any idea what it might be ?
Internal error. To see this error please display the PHP errors.
You can find all the mandatory fields in the classes/Product.php you need to find $definition attribute there. All fields are listed there. If the field has a key “required” it means that the field is required.
Nice article. You know how fields are required if I want create new product via REST service?
I am working on the 1.6 version and I have tried to enable REST webservice from localhost.
when I visit this link
I can’t get any xml .. the only page that I see is the 404 http_error.
Have you any idea about that ?
thanks in advance..
Hi, I am trying to create order using prestashop 22.214.171.124 webservice. I could add customer, address, and cart but while creating order, it’s throwing error orderDetail->product_name is empty. Product is also not shown in cart and order. after adding order all amount values are shown zero. please suggest any workaround
Try to activate ‘display_errors’ function in defines.inc.php, look what error you will get doing put request, and send it to us.
Hi, Thanks for this post!