Recent Bloggers

Ankit Prajapati
Posts: 5
Stars: 0
Date: 9/18/17
Chirag Patel
Posts: 4
Stars: 0
Date: 9/15/17
Rahul Joshi
Posts: 5
Stars: 0
Date: 9/15/17
Jiten Vaghela
Posts: 1
Stars: 0
Date: 8/23/17
Kuldeep Acharya
Posts: 1
Stars: 0
Date: 8/16/17
Saurang Suthar
Posts: 5
Stars: 0
Date: 7/5/17
Jyoti Verma
Posts: 3
Stars: 0
Date: 6/29/17
Pankti Patel
Posts: 1
Stars: 0
Date: 5/27/17
Chandrika Baraiya
Posts: 5
Stars: 0
Date: 5/27/17
Atith Patel
Posts: 5
Stars: 0
Date: 5/23/17
« Back

How to access PrestaShop Web Services

Prestashop allows access to shop’s database for external applications through web services in form of a CRUD API. You can access web services of prestashop using webservice key, prestashop allow you to create multiple web service key with different prestashop resource access permission.

Generate Prestashop Webservice key

  • Go into your Prestashop Back Office and click on the ADVANCED PARAMETERS ? Webservice

  • Click on Add new webservice key

 

1.png

 

  • Click the Generate button to generate web service authentication key.

  • You can also create your own key but it must be 32 characters long.

  • Using a generated key prevents Unauthorized user from guessing your key.

 

5.png

 

  • web service key provides a way to authorised users to access the web service.

    • Key description is not public, but you can use it for uniquely identified your key.

  • Status use for grant access to your data from a certain key temporarily.

  • Permissions is very important part which enables you to assign rights for each resource to make available for this key.

  • Make sure following options must be yes

    • Enable PrestaShop webservice

    • Enable CGI mode for PHP

 

6.png

 

Access prestashop web service in browser


 

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">

<api shop_name="test prestashop">

<addresses xlink:href="http://shop.prestashop.com/api/addresses" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/addresses" get="true" put="true" post="true" delete="true" head="true">The Customer, Manufacturer and Customer addresses</description>

<schema xlink:href="http://shop.prestashop.com/api/addresses?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/addresses?schema=synopsis" type="synopsis"/>

</addresses>

<carriers xlink:href="http://shop.prestashop.com/api/carriers" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/carriers" get="true" put="true" post="true" delete="true" head="true">The Carriers</description>

<schema xlink:href="http://shop.prestashop.com/api/carriers?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/carriers?schema=synopsis" type="synopsis"/>

</carriers>

<cart_rules xlink:href="http://shop.prestashop.com/api/cart_rules" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/cart_rules" get="true" put="true" post="true" delete="true" head="true">Cart rules management</description>

<schema xlink:href="http://shop.prestashop.com/api/cart_rules?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/cart_rules?schema=synopsis" type="synopsis"/>

</cart_rules>

<carts xlink:href="http://shop.prestashop.com/api/carts" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/carts" get="true" put="true" post="true" delete="true" head="true">Customer's carts</description>

<schema xlink:href="http://shop.prestashop.com/api/carts?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/carts?schema=synopsis" type="synopsis"/>

</carts>

<categories xlink:href="http://shop.prestashop.com/api/categories" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/categories" get="true" put="true" post="true" delete="true" head="true">The product categories</description>

<schema xlink:href="http://shop.prestashop.com/api/categories?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/categories?schema=synopsis" type="synopsis"/>

</categories>

 

  • If get, put, post, and delete attributes have true value, It means that you have all permission of that resource.

  • Using XLink, you will be able to access various resources. XLink associates an XML file to another XML file using link.

  • Each element contains a description of the resource, and two schemas:

    • blank is use to create a new item.

      • http://shop.prestashop.com/api/categories?schema=blank

    • synopsis is just like the blank one but with a detailed description of what type of data is expected in each element.

      • http://shop.prestashop.com/api/categories?schema=synopsis

 

<categories xlink:href="http://shop.prestashop.com/api/categories" get="true" put="true" post="true" delete="true" head="true">

<description xlink:href="http://shop.prestashop.com/api/categories" get="true" put="true" post="true" delete="true" head="true">The product categories</description>

<schema xlink:href="http://shop.prestashop.com/api/categories?schema=blank" type="blank"/>

<schema xlink:href="http://shop.prestashop.com/api/categories?schema=synopsis" type="synopsis"/>

</categories>

  • To get a list of resource category use xlink

    • http://shop.prestashop.com/api/categories

 

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">

   <categories>

       <category id="1" xlink:href="http://shop.prestashop.com/api/categories/1"/>

       <category id="2" xlink:href="http://shop.prestashop.com/api/categories/2"/>

   </categories>

</prestashop>

Adding and editing a resource

  • To add a category or any other resource

    • GET the XML blank data of resource

      • Example : http://prestashop-url/api/categories?schema=blank

    • Fill it with new data, and POST the whole XML file to the /api/categories/ URL again.

    • PrestaShop will take care of adding everything in the database.

    • It will return an XML file indicating that the operation has been successful, along with the ID of the newly created customer.

  • To edit an existing resource

    • GET the full XML file of resource you want to change (/api/categories/2), edit its content as needed, then PUT the whole XML file back to the same URL again.
Comments
No comments yet. Be the first.

Contact Us

Loading

Get in touch

Headquarter :
302, Landmark,
Nr. Titanium City Center,
Prahlad Nagar Road,
Ahmedabad, India - 380015.